08/30

parent 70c8ee3d
Quintiq file version 2.0
#parent: #root
Relation Warehouse_MacroPlan_MacroPlan_Warehouse
{
#keys: '1[413182.1.1824597111]'
DefaultRelationStrategy
{
}
RelationSide.LeftSide MacroPlan
{
#keys: '3[413182.1.1824597113][413182.1.1824597112][413182.1.1824597114]'
Cardinality: '0to1'
ObjectDefinition: Warehouse
OwningSide: 'Reference'
}
RelationSide.RightSide Warehouse
{
#keys: '3[413182.1.1824597116][413182.1.1824597115][413182.1.1824597117]'
Cardinality: '0to1'
ObjectDefinition: MacroPlan
OwningSide: 'Owned'
}
}
......@@ -21,8 +21,8 @@ MethodOverride ExecuteDB (
o := this
->SetStatusInProgress()
->|mpsync->ExecuteDBUserImportProfiles( macroplan,importprofiles,uniqueimportobjectgroupinprofiles,isrefreshfromsource,isoverwritemanualconfig,binarydatas,brokers)
//->|mp->ImportAllMPData()
//->|mpsync->ExecuteDBUserImportProfiles( macroplan,importprofiles,uniqueimportobjectgroupinprofiles,isrefreshfromsource,isoverwritemanualconfig,binarydatas,brokers)
->|mp->ImportAllMPData()
->|this->SetStatusDone()
->|mp->SetLastImportTime()
->|this->deleteuserimportfile(userprofile)
......
......@@ -19,16 +19,75 @@ Method SyncPlannedOrdersFromMacroPlan00 (
//输液拆批
periodshuye:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()<>'口服')
periodshuye:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='输液',ui.QuantityToProcess()>0)
routingshuye := selectset( macroplan, Routing, r,r.ProductType()='输液');
//输液成品两周数量一聚合
h:=Duration::Days(14)
periodsy1:=construct( PeriodTask_MPs );
ma:=max(periodshuye,Elements,p1,p1.Start())
mi:=min(periodshuye,Elements,p1,p1.Start())
while(mi<=ma){
c:=Duration::Days(14)
mi:=min(periodshuye,Elements,p1,p1.Start())+h
periodsy2:=selectset(periodshuye,Elements,p,p.Start()<mi and p.Start()>=(mi-c) )
traverse( periodsy2,Elements,p9){
p9.Earlystart(mi-c)
periodsy1.Add( p9)
}
h:=h+c
}
periodsy3:=periodsy1
periodsy4:=construct( PeriodTask_MPs)
traverse( periodsy1,Elements,p5){
v:=min(periodsy3,Elements,p9,p9.Start())
mi:=v+h
all:=0.0000
traverse( periodsy3,Elements,p3){
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().RoutingID()=p3.astype(PeriodTaskOperation ).Operation().RoutingID() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p3.QuantityToProcess()
}
}
p5.TotalQu(all)
if( periodsy4.Size()<1){
periodsy4.Add( p5)
}else{
if ( forallexists( periodsy4,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().RoutingID()=p5.astype(PeriodTaskOperation ).Operation().RoutingID() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
periodsy4.Add( p5)
}
}
}
routingshuye := selectset( macroplan, Routing, r,r.ProductType()<>'口服');
traverse( routingshuye,Elements,ro)
{
//优先级
priority:=999
traverse(periodshuye, Elements, p ){
traverse(periodsy4, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
......@@ -40,7 +99,8 @@ Method SyncPlannedOrdersFromMacroPlan00 (
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.QuantityToProcess()
qty:=p.TotalQu()
time:=p.Earlystart()
if( ls.Routing().Batch().Length()>0){
quantitys:=construct(Reals);
......@@ -65,13 +125,38 @@ Method SyncPlannedOrdersFromMacroPlan00 (
value:=sum( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
difference:=qty*10000-(value*a)
if( ls.Routing().Sales().LikeUserLocale("内销")){
if( ls.Routing().Sales().LikeUserLocale("内销") or ls.Routing().Sales().LikeUserLocale("独立需求") ){
if(a>=1 and difference>0){
min1:=min( quantitys,Elements,qu,qu)
if( p.ProductID().LikeUserLocale( 'D11109') or p.ProductID().LikeUserLocale( 'D11110') or p.ProductID().LikeUserLocale( 'D53040') or p.ProductID().LikeUserLocale( 'DD3001') or p.ProductID().LikeUserLocale( 'DD3001') or p.ProductID().LikeUserLocale( 'DD6001') or p.ProductID().LikeUserLocale( 'DD6003') or p.ProductID().LikeUserLocale( 'DD3701') or p.ProductID().LikeUserLocale( 'DD3703') or p.ProductID().LikeUserLocale( 'DD6701') or p.ProductID().LikeUserLocale( 'DD6703') or p.ProductID().LikeUserLocale( 'D31094U')){
if( ro.SCALE()<=1.5){
if(a<1 and difference<min1){
difference:=2 * min1
}
}else{
a:=0
difference:=0.0
}
}else{
difference:=0.0
}
a:=a+1
difference:=difference-value
}
}
for( i:=a;i>0;i:=i - 1){
......@@ -79,29 +164,40 @@ Method SyncPlannedOrdersFromMacroPlan00 (
rs.Add( s)
}
}
all:= this.AllQuantity0( quantitys,difference,rs,ls.Routing().Sales(),ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
if( qua > 0.0 and ls.Routing().Sales()<>'渠道-外贸' )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,priority);
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,time,p.UnitPeriod().End(),cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
if( qty > 0.0 and ls.Routing().Sales()<>'渠道-外贸')
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,1);
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,time,p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}}
}}
......@@ -112,7 +208,7 @@ Method SyncPlannedOrdersFromMacroPlan00 (
periodkf := selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='口服')
periodkf := selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='口服',ui.QuantityToProcess()>0)
routingkf := selectset( macroplan, Routing, r,r.ProductType()='口服');
......@@ -133,10 +229,6 @@ Method SyncPlannedOrdersFromMacroPlan00 (
all:=all+p2.QuantityToProcess()
}
}
if(all=0){
......@@ -171,9 +263,10 @@ Method SyncPlannedOrdersFromMacroPlan00 (
period5:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='SF')
//period5:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='SF')
period5:=selectset(period14,Elements,p,true)
period11:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
//period11:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
//半成品三周数量一聚合
......@@ -213,15 +306,7 @@ Method SyncPlannedOrdersFromMacroPlan00 (
traverse( period6,Elements,p3){
if( p3.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p3.astype( PeriodTaskOperation ).Operation().Ismd()=1){
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().Linkid()=p3.astype(PeriodTaskOperation).Operation().Linkid() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
......@@ -276,7 +361,9 @@ Method SyncPlannedOrdersFromMacroPlan00 (
period12:=period11.Union( periods7)
//period12:=period11.Union( periods7)
period12:=periods7
......@@ -308,19 +395,29 @@ Method SyncPlannedOrdersFromMacroPlan00 (
qty:=p.TotalQu()
time:=p.Start()
endtime:=p.UnitPeriod().End()
if( ls.Routing().MaterialType()='PF' and not(p.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p.astype( PeriodTaskOperation ).Operation().Ismd()=1)){
// if( ls.Routing().MaterialType()='PF' and not(p.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p.astype( PeriodTaskOperation ).Operation().Ismd()=1)){
//
// qty:=p.QuantityToProcess()
// time:=p.Start()
// }
//
// if( ls.Routing().MaterialType()='SF'){
// time:=p.Earlystart()
//
// b:=Duration::Days(21)
// endtime:=p.Earlystart()+b
// }
time:=p.Earlystart()
b:=Duration::Days(21)
endtime:=p.Earlystart()+b
qty:=p.QuantityToProcess()
time:=p.Start()
}
if( ls.Routing().MaterialType()='SF'){
time:=p.Earlystart()
}
if( ls.Routing().Batch().Length()>0 ){
quantitys:=construct(Reals);
......@@ -363,7 +460,7 @@ Method SyncPlannedOrdersFromMacroPlan00 (
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,time,p.UnitPeriod().End(),cc,priority);
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),endtime,mpsplanid,qua,time,endtime,cc,priority);
updates.Add( ioplannedorder );
}
}
......@@ -376,7 +473,7 @@ Method SyncPlannedOrdersFromMacroPlan00 (
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,time,p.UnitPeriod().End(),cc,1);
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),endtime,mpsplanid,qty*10000,time,endtime,cc,1);
updates.Add( ioplannedorder );
}}
}}
......@@ -384,6 +481,34 @@ Method SyncPlannedOrdersFromMacroPlan00 (
}
periodother:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()<>'输液' and ui.astype( PeriodTaskOperation ).Operation().ProductType() <>'口服' )
traverse(periodother, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
qty:=p.QuantityToProcess()
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}
}
// Get the set of old PlannedOrder to be deleted
tobedeleteset := existing.Difference( updates );
......
Quintiq file version 2.0
#parent: #root
Method SyncPlannedOrdersFromMacroPlan000 (
MacroPlan macroplan,
String mpsplanid
)
{
Description: 'Create planned orders from period tasks from macroplan.'
TextBody:
[*
existing := this.IOMPSPlannedOrder( relget );
updates := construct( IOMPSPlannedOrders );
conv := DateTimeToString::StandardConverter();
num:=NumberToString::StandardConverter()
// Get periods within the planning horizon
//输液拆批
periodshuye:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()<>'口服')
routingshuye := selectset( macroplan, Routing, r,r.ProductType()<>'口服');
traverse( routingshuye,Elements,ro)
{
//优先级
priority:=999
traverse(periodshuye, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
difference:=0.0
a:=0
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.QuantityToProcess()
if( ls.Routing().Batch().Length()>0){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
value:=sum( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
difference:=qty*10000-(value*a)
if( ls.Routing().Sales().LikeUserLocale("内销")){
if(a>=1 and difference>0){
a:=a+1
difference:=difference-value
}
}
for( i:=a;i>0;i:=i - 1){
traverse( quantitys,Elements,s){
rs.Add( s)
}
}
all:= this.AllQuantity0( quantitys,difference,rs,ls.Routing().Sales(),ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}}
}}
}
}
periodkf := selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='口服')
routingkf := selectset( macroplan, Routing, r,r.ProductType()='口服');
period1 :=selectset(periodkf,Elements,ui,ui.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and ui.astype( PeriodTaskOperation ).Operation().Ismd()=1)
period3 :=selectset(periodkf,Elements,ui,not(ui.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and ui.astype( PeriodTaskOperation ).Operation().Ismd()=1))
period1:=selectsortedset( period1,Elements,p,p.astype( PeriodTaskOperation ).Operation().RoutingID())
//多设备
periods2:=construct( PeriodTask_MPs)
traverse( period1,Elements,p1){
all:=0.0000
traverse( period1,Elements,p2){
if( p1.UnitPeriod().End()=p2.UnitPeriod().End() and p1.UnitPeriod().Start()=p2.UnitPeriod().Start() and p1.astype(PeriodTaskOperation).Operation().RoutingName()=p2.astype(PeriodTaskOperation).Operation().RoutingName() and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p2.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p2.QuantityToProcess()
}
}
if(all=0){
all:=p1.QuantityToProcess()
}
p1.TotalQu(all)
if( periods2.Size()<1){
periods2.Add( p1)
}else{
if ( forallexists( periods2,Elements,p,
not(p1.UnitPeriod().End()=p.UnitPeriod().End() and p1.UnitPeriod().Start()=p.UnitPeriod().Start() and p1.astype(PeriodTaskOperation).Operation().RoutingName()=p.astype(PeriodTaskOperation).Operation().RoutingName() and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p.astype(PeriodTaskOperation).Operation().RoutingStepName() )) )
{
periods2.Add( p1)
}
}
}
period14:=period3.Union( periods2)
period5:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='SF')
period11:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
//半成品三周数量一聚合
b:=Duration::Days(21)
period10:=construct( PeriodTask_MPs );
q:=max(period5,Elements,p1,p1.Start())
end:=min(period5,Elements,p1,p1.Start())
while(end<=q){
c:=Duration::Days(21)
end:=min(period5,Elements,p1,p1.Start())+b
periods9:=selectset(period5,Elements,p,p.Start()<end and p.Start()>=(end-c) )
traverse( periods9,Elements,p9){
p9.Earlystart(end-c)
period10.Add( p9)
}
b:=b+c
}
period6:=period10
periods7:=construct( PeriodTask_MPs)
traverse( period10,Elements,p5){
v:=min(period6,Elements,p9,p9.Start())
end:=v+b
all:=0.0000
traverse( period6,Elements,p3){
if( p3.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p3.astype( PeriodTaskOperation ).Operation().Ismd()=1){
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().Linkid()=p3.astype(PeriodTaskOperation).Operation().Linkid() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p3.TotalQu()
}
}else{
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().RoutingID()=p3.astype(PeriodTaskOperation ).Operation().RoutingID() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p3.QuantityToProcess()
}
}
}
p5.TotalQu(all)
if( periods7.Size()<1){
periods7.Add( p5)
}else{
if( p5.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p5.astype( PeriodTaskOperation ).Operation().Ismd()=1){
if ( forallexists( periods7,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().Linkid()=p5.astype(PeriodTaskOperation ).Operation().Linkid() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
periods7.Add( p5)
}
}else{
if ( forallexists( periods7,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().RoutingID()=p5.astype(PeriodTaskOperation ).Operation().RoutingID() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
periods7.Add( p5)
}
}
}
}
period12:=period11.Union( periods7)
//口服拆批
// Group by Period, RoutingID
traverse( routingkf,Elements,ro)
{
//优先级
priority:=999
traverse(period12, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
difference:=0.0
a:=0
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.TotalQu()
time:=p.Start()
if( ls.Routing().MaterialType()='PF' and not(p.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p.astype( PeriodTaskOperation ).Operation().Ismd()=1)){
qty:=p.QuantityToProcess()
time:=p.Start()
}
if( ls.Routing().MaterialType()='SF'){
time:=p.Earlystart()
}
if( ls.Routing().Batch().Length()>0 ){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
//输液按整天拆,口服按最大批量
value:=max( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
difference:=qty*10000-(value*a)
for( i:=a;i>0;i:=i - 1){
rs.Add( value)
}
all:= this.AllQuantity( quantitys,difference,rs,"",ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,time,p.UnitPeriod().End(),cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,time,p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}}
}}
}
}
// Get the set of old PlannedOrder to be deleted
tobedeleteset := existing.Difference( updates );
traverse( tobedeleteset, Elements, ele )
{
ele.Delete();
}
*]
}
Quintiq file version 2.0
#parent: #root
Method SyncPlannedOrdersFromMacroPlan0000 (
MacroPlan macroplan,
String mpsplanid
)
{
Description: 'Create planned orders from period tasks from macroplan.'
TextBody:
[*
existing := this.IOMPSPlannedOrder( relget );
updates := construct( IOMPSPlannedOrders );
conv := DateTimeToString::StandardConverter();
num:=NumberToString::StandardConverter()
// Get periods within the planning horizon
//输液拆批
periodshuye:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='输液',ui.QuantityToProcess()>0)
routingshuye := selectset( macroplan, Routing, r,r.ProductType()='输液');
//输液成品两周数量一聚合
h:=Duration::Days(14)
periodsy1:=construct( PeriodTask_MPs );
ma:=max(periodshuye,Elements,p1,p1.Start())
mi:=min(periodshuye,Elements,p1,p1.Start())
while(mi<=ma){
c:=Duration::Days(14)
mi:=min(periodshuye,Elements,p1,p1.Start())+h
periodsy2:=selectset(periodshuye,Elements,p,p.Start()<mi and p.Start()>=(mi-c) )
traverse( periodsy2,Elements,p9){
p9.Earlystart(mi-c)
periodsy1.Add( p9)
}
h:=h+c
}
periodsy3:=selectsortedset( periodsy1,Elements,p,true)
periodsy4:=construct( PeriodTask_MPs)
traverse( periodsy1,Elements,p5){
v:=min(periodsy3,Elements,p9,p9.Start())
mi:=v+h
all:=0.0000
traverse( periodsy3,Elements,p3){
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().RoutingID()=p3.astype(PeriodTaskOperation ).Operation().RoutingID() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p3.QuantityToProcess()
}
}
p5.TotalQu(all)
if( periodsy4.Size()<1){
periodsy4.Add( p5)
}else{
if ( forallexists( periodsy4,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().RoutingID()=p5.astype(PeriodTaskOperation ).Operation().RoutingID() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
periodsy4.Add( p5)
}
}
}
traverse( routingshuye,Elements,ro)
{
//优先级
priority:=999
traverse(periodsy4, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
difference:=0.0
a:=0
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.TotalQu()
time:=p.Earlystart()
if( ls.Routing().Batch().Length()>0){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
value:=sum( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
difference:=qty*10000-(value*a)
if( ls.Routing().Sales().LikeUserLocale("内销") or ls.Routing().Sales().LikeUserLocale("独立需求") ){
min1:=min( quantitys,Elements,qu,qu)
if( p.ProductID().LikeUserLocale( 'D11109') or p.ProductID().LikeUserLocale( 'D11110') or p.ProductID().LikeUserLocale( 'D53040') or p.ProductID().LikeUserLocale( 'DD3001') or p.ProductID().LikeUserLocale( 'DD3001') or p.ProductID().LikeUserLocale( 'DD6001') or p.ProductID().LikeUserLocale( 'DD6003') or p.ProductID().LikeUserLocale( 'DD3701') or p.ProductID().LikeUserLocale( 'DD3703') or p.ProductID().LikeUserLocale( 'DD6701') or p.ProductID().LikeUserLocale( 'DD6703') or p.ProductID().LikeUserLocale( 'D31094U')){
if( ro.SCALE()<=1.5){
if(a<1 and difference<min1){
difference:=2 * min1
}
}else{
a:=0
difference:=0.0
}
}else{
difference:=0.0
}
}
for( i:=a;i>0;i:=i - 1){
traverse( quantitys,Elements,s){
rs.Add( s)
}
}
all:= this.AllQuantity0( quantitys,difference,rs,ls.Routing().Sales(),ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 and ls.Routing().Sales()<>'渠道-外贸' )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,time,p.UnitPeriod().End(),cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 and ls.Routing().Sales()<>'渠道-外贸')
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,time,p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}}
}}
}
}
periodkf := selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='口服',ui.QuantityToProcess()>0)
routingkf := selectset( macroplan, Routing, r,r.ProductType()='口服');
period1 :=selectset(periodkf,Elements,ui,ui.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and ui.astype( PeriodTaskOperation ).Operation().Ismd()=1)
period3 :=selectset(periodkf,Elements,ui,not(ui.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and ui.astype( PeriodTaskOperation ).Operation().Ismd()=1))
period1:=selectsortedset( period1,Elements,p,p.astype( PeriodTaskOperation ).Operation().RoutingID())
//多设备
periods2:=construct( PeriodTask_MPs)
traverse( period1,Elements,p1){
all:=0.0000
traverse( period1,Elements,p2){
if( p1.UnitPeriod().End()=p2.UnitPeriod().End() and p1.UnitPeriod().Start()=p2.UnitPeriod().Start() and p1.astype(PeriodTaskOperation).Operation().RoutingName()=p2.astype(PeriodTaskOperation).Operation().RoutingName() and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p2.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p2.QuantityToProcess()
}
}
if(all=0){
all:=p1.QuantityToProcess()
}
p1.TotalQu(all)
if( periods2.Size()<1){
periods2.Add( p1)
}else{
if ( forallexists( periods2,Elements,p,
not(p1.UnitPeriod().End()=p.UnitPeriod().End() and p1.UnitPeriod().Start()=p.UnitPeriod().Start() and p1.astype(PeriodTaskOperation).Operation().RoutingName()=p.astype(PeriodTaskOperation).Operation().RoutingName() and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p.astype(PeriodTaskOperation).Operation().RoutingStepName() )) )
{
periods2.Add( p1)
}
}
}
period14:=period3.Union( periods2)
//period5:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='SF')
period5:=selectset(period14,Elements,p,true)
//period11:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
//半成品三周数量一聚合
//成品三周一聚合
b:=Duration::Days(21)
period10:=construct( PeriodTask_MPs );
q:=max(period5,Elements,p1,p1.Start())
end:=min(period5,Elements,p1,p1.Start())
while(end<=q){
c:=Duration::Days(21)
end:=min(period5,Elements,p1,p1.Start())+b
periods9:=selectset(period5,Elements,p,p.Start()<end and p.Start()>=(end-c) )
traverse( periods9,Elements,p9){
p9.Earlystart(end-c)
period10.Add( p9)
}
b:=b+c
}
period6:=period10
periods7:=construct( PeriodTask_MPs)
traverse( period10,Elements,p5){
v:=min(period6,Elements,p9,p9.Start())
end:=v+b
all:=0.0000
traverse( period6,Elements,p3){
if( p3.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p3.astype( PeriodTaskOperation ).Operation().Ismd()=1){
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().Linkid()=p3.astype(PeriodTaskOperation).Operation().Linkid() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p3.TotalQu()
}
}else{
if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().RoutingID()=p3.astype(PeriodTaskOperation ).Operation().RoutingID() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p3.QuantityToProcess()
}
}
}
p5.TotalQu(all)
if( periods7.Size()<1){
periods7.Add( p5)
}else{
if( p5.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p5.astype( PeriodTaskOperation ).Operation().Ismd()=1){
if ( forallexists( periods7,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().Linkid()=p5.astype(PeriodTaskOperation ).Operation().Linkid() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
periods7.Add( p5)
}
}else{
if ( forallexists( periods7,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().RoutingID()=p5.astype(PeriodTaskOperation ).Operation().RoutingID() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
periods7.Add( p5)
}
}
}
}
//同规格聚合
period15:=selectset(periods7,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
periods16:=construct( PeriodTask_MPs)
traverse( period15,Elements,p1){
all:=0.0000
strings1:=p1.astype(PeriodTaskOperation).Operation().RoutingID().Tokenize( '-')
s1:=strings1.Element( 0)
traverse( period15,Elements,p2){
if( p1.Earlystart()=p2.Earlystart() and p2.astype(PeriodTaskOperation ).Operation().RoutingID().LikeUserLocale(s1) and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p2.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p2.TotalQu()
}
}
if(all=0){
all:=p1.TotalQu()
}
p1.TotalQu(all)
if( periods16.Size()<1){
periods16.Add( p1)
}else{
if ( forallexists( periods16,Elements,p,
not(p1.Earlystart()=p.Earlystart() and p.astype(PeriodTaskOperation ).Operation().RoutingID().LikeUserLocale(s1) and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p.astype(PeriodTaskOperation).Operation().RoutingStepName() )) )
{
periods16.Add( p1)
}
}
}
//period12:=period11.Union( periods7)
//period12:=periods7
period17:=selectset(periods7,Elements,p,not p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
periods18:=construct( PeriodTask_MPs)
//traverse( period17,Elements,p17){
//
//
// //判断是否存在这个
// strings1:=p17.astype(PeriodTaskOperation).Operation().RoutingID().Tokenize( '-')
// s1:=strings1.Element( 0)
// pt:=selectset( periods16,Elements,p,p.astype( PeriodTaskOperation ).Operation().RoutingID().LikeUserLocale( s1))
// if( isnull( pt)){
//
//
//
// }else{
//
// traverse( pt,Elements,p16){
//
// if( p16.astype( PeriodTaskOperation ).Operation().RoutingID().LikeUserLocale( s1) and p16.Earlystart()=p17.Earlystart()){
//
//
// p16.TotalQu(p17.TotalQu())
//
// periods18.Add( p16)
// }
// }
//
//
//
//
// }
// }
period12:=period17.Union( periods18)
routingpf := selectset( macroplan, Routing, r,r.ProductType()='口服' and r.MaterialType()='PF');
routingsf := selectset( macroplan, Routing, r,r.ProductType()='口服' and r.MaterialType()='SF');
//口服拆批
// Group by Period, RoutingID
traverse( routingpf,Elements,ro)
{
//优先级
priority:=999
traverse(periods16, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
difference:=0.0
a:=0
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.TotalQu()
time:=p.Start()
endtime:=p.UnitPeriod().End()
// if( ls.Routing().MaterialType()='PF' and not(p.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p.astype( PeriodTaskOperation ).Operation().Ismd()=1)){
//
// qty:=p.QuantityToProcess()
// time:=p.Start()
// }
//
// if( ls.Routing().MaterialType()='SF'){
// time:=p.Earlystart()
//
// b:=Duration::Days(21)
// endtime:=p.Earlystart()+b
// }
time:=p.Earlystart()
b:=Duration::Days(21)
endtime:=p.Earlystart()+b
if( ls.Routing().Batch().Length()>0 ){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
//输液按整天拆,口服按最大批量
value:=max( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
// difference:=qty*10000-(value*a)
for( i:=a;i>0;i:=i - 1){
rs.Add( value)
}
all:= this.AllQuantity( quantitys,difference,rs,"",ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),endtime,mpsplanid,qua,time,endtime,cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),endtime,mpsplanid,qty*10000,time,endtime,cc,1);
updates.Add( ioplannedorder );
}}
}}
}
}
traverse( routingpf,Elements,ro)
{
//优先级
priority:=999
strings1:=ro.ID().Tokenize( '-')
s1:=strings1.Element( 0)
traverse(periods16, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
traverse( routingsf,Elements,kf){
if(kf.ID().LikeUserLocale(s1)){
difference:=0.0
a:=0
qty:=p.TotalQu()
time:=p.Start()
endtime:=p.UnitPeriod().End()
time:=p.Earlystart()
b:=Duration::Days(21)
endtime:=p.Earlystart()+b
if( ls.Routing().Batch().Length()>0 ){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
//输液按整天拆,口服按最大批量
value:=max( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
// difference:=qty*10000-(value*a)
for( i:=a;i>0;i:=i - 1){
rs.Add( value)
}
all:= this.AllQuantity( quantitys,difference,rs,"",ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= kf.ID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,kf.ID(),endtime,mpsplanid,qua,time,endtime,cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= kf.ID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,kf.ID(),endtime,mpsplanid,qty*10000,time,endtime,cc,1);
updates.Add( ioplannedorder );
}
}}
}}
}}
}
periodother:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()<>'输液' and ui.astype( PeriodTaskOperation ).Operation().ProductType() <>'口服' )
traverse(periodother, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
qty:=p.QuantityToProcess()
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}
}
// Get the set of old PlannedOrder to be deleted
tobedeleteset := existing.Difference( updates );
traverse( tobedeleteset, Elements, ele )
{
ele.Delete();
}
*]
}
Quintiq file version 2.0
#parent: #root
Method SyncPlannedOrdersFromMacroPlan0001 (
MacroPlan macroplan,
String mpsplanid
)
{
Description:
[*
Create planned orders from period tasks from macroplan.
不聚合时间
*]
TextBody:
[*
existing := this.IOMPSPlannedOrder( relget );
updates := construct( IOMPSPlannedOrders );
conv := DateTimeToString::StandardConverter();
num:=NumberToString::StandardConverter()
// Get periods within the planning horizon
//输液拆批
periodshuye:= selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()<>'口服')
routingshuye := selectset( macroplan, Routing, r,r.ProductType()<>'口服');
traverse( routingshuye,Elements,ro)
{
//优先级
priority:=999
traverse(periodshuye, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
difference:=0.0
a:=0
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.QuantityToProcess()
if( ls.Routing().Batch().Length()>0){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
value:=sum( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
difference:=qty*10000-(value*a)
if( ls.Routing().Sales().LikeUserLocale("内销")){
if(a>=1 and difference>0){
a:=a+1
difference:=difference-value
}
}
for( i:=a;i>0;i:=i - 1){
traverse( quantitys,Elements,s){
rs.Add( s)
}
}
all:= this.AllQuantity0( quantitys,difference,rs,ls.Routing().Sales(),ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(p.UnitPeriod().Start())).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,p.UnitPeriod().Start(),p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}}
}}
}
}
periodkf := selectset(macroplan,UnitPeriod.PeriodTask_MP,ui,ui.astype( PeriodTaskOperation ).Operation().ProductType()='口服')
routingkf := selectset( macroplan, Routing, r,r.ProductType()='口服');
period1 :=selectset(periodkf,Elements,ui,ui.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and ui.astype( PeriodTaskOperation ).Operation().Ismd()=1)
period3 :=selectset(periodkf,Elements,ui,not(ui.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and ui.astype( PeriodTaskOperation ).Operation().Ismd()=1))
period1:=selectsortedset( period1,Elements,p,p.astype( PeriodTaskOperation ).Operation().RoutingID())
//多设备
periods2:=construct( PeriodTask_MPs)
traverse( period1,Elements,p1){
all:=0.0000
traverse( period1,Elements,p2){
if( p1.UnitPeriod().End()=p2.UnitPeriod().End() and p1.UnitPeriod().Start()=p2.UnitPeriod().Start() and p1.astype(PeriodTaskOperation).Operation().RoutingName()=p2.astype(PeriodTaskOperation).Operation().RoutingName() and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p2.astype(PeriodTaskOperation).Operation().RoutingStepName()){
all:=all+p2.QuantityToProcess()
}
}
if(all=0){
all:=p1.QuantityToProcess()
}
p1.TotalQu(all)
if( periods2.Size()<1){
periods2.Add( p1)
}else{
if ( forallexists( periods2,Elements,p,
not(p1.UnitPeriod().End()=p.UnitPeriod().End() and p1.UnitPeriod().Start()=p.UnitPeriod().Start() and p1.astype(PeriodTaskOperation).Operation().RoutingName()=p.astype(PeriodTaskOperation).Operation().RoutingName() and p1.astype(PeriodTaskOperation).Operation().RoutingStepName()=p.astype(PeriodTaskOperation).Operation().RoutingStepName() )) )
{
periods2.Add( p1)
}
}
}
period14:=period3.Union( periods2)
//period5:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='SF')
period11:=selectset(period14,Elements,p,p.astype(PeriodTaskOperation ).Operation().MaterialType()='PF')
//半成品三周数量一聚合
// b:=Duration::Days(21)
//
//
//
//period10:=construct( PeriodTask_MPs );
//
// q:=max(period5,Elements,p1,p1.Start())
// end:=min(period5,Elements,p1,p1.Start())
//
//while(end<=q){
//
//c:=Duration::Days(21)
//end:=min(period5,Elements,p1,p1.Start())+b
//periods9:=selectset(period5,Elements,p,p.Start()<end and p.Start()>=(end-c) )
//
//traverse( periods9,Elements,p9){
// p9.Earlystart(end-c)
// period10.Add( p9)
// }
//b:=b+c
//}
//
//period6:=period10
//
//
// periods7:=construct( PeriodTask_MPs)
// traverse( period10,Elements,p5){
//
// v:=min(period6,Elements,p9,p9.Start())
// end:=v+b
//
// all:=0.0000
// traverse( period6,Elements,p3){
//
//
//
//
//
//
//
//
//
//
//
// if( p3.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p3.astype( PeriodTaskOperation ).Operation().Ismd()=1){
//
// if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().Linkid()=p3.astype(PeriodTaskOperation).Operation().Linkid() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
// all:=all+p3.TotalQu()
// }
//
//
//
//
// }else{
// if( p3.Earlystart()=p5.Earlystart() and p5.astype(PeriodTaskOperation).Operation().RoutingID()=p3.astype(PeriodTaskOperation ).Operation().RoutingID() and p3.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()){
// all:=all+p3.QuantityToProcess()
// }
//
//
// }
//
//
//
//
// }
//
// p5.TotalQu(all)
// if( periods7.Size()<1){
//
// periods7.Add( p5)
// }else{
//
//
// if( p5.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p5.astype( PeriodTaskOperation ).Operation().Ismd()=1){
// if ( forallexists( periods7,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().Linkid()=p5.astype(PeriodTaskOperation ).Operation().Linkid() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
//
// periods7.Add( p5)
// }
//
//
// }else{
//
// if ( forallexists( periods7,Elements,p,not(p.Earlystart()=p5.Earlystart() and p.astype(PeriodTaskOperation ).Operation().RoutingID()=p5.astype(PeriodTaskOperation ).Operation().RoutingID() and p.astype(PeriodTaskOperation).Operation().RoutingStepName()=p5.astype(PeriodTaskOperation).Operation().RoutingStepName()))){
//
// periods7.Add( p5)
// }
//
// }
//
//
//
//}
// }
//
//
//
//period12:=period11.Union( periods7)
//口服拆批
// Group by Period, RoutingID
traverse( routingkf,Elements,ro)
{
//优先级
priority:=999
traverse(period14, Elements, p ){
ls:=p.astype( PeriodTaskOperation ).Operation().RoutingStep()
random:=0
if( (not isnull( p.astype( PeriodTaskOperation ).Operation())) and (not isnull(ro.FirstStep()))){
if( p.OPID()=ro.FirstStep().FirstOperation().ID()){
difference:=0.0
a:=0
//qty := sum( ls, Operation.PeriodTaskOperation, pto, pto.Quantity() > 0.0 and pto.UnitPeriod().Period_MP() = p, pto.Quantity() );
// qty:=p.QuantityToProcess()
qty:=p.QuantityToProcess()
time:=p.Start()
if( not(p.astype( PeriodTaskOperation ).Operation().Linkid().Length()>0 and p.astype( PeriodTaskOperation ).Operation().Ismd()=1)){
qty:=p.QuantityToProcess()
time:=p.Start()
}else{
qty:=p.TotalQu()
}
// if( ls.Routing().MaterialType()='SF'){
// time:=p.Earlystart()
//
// }
//
if( ls.Routing().Batch().Length()>0 ){
quantitys:=construct(Reals);
all:=construct( Reals);
c:=StringToReal::StandardConverter()
if(ls.Routing().Batch().LikeUserLocale(";") ){
strings:=ls.Routing().Batch().Tokenize(";")
traverse( strings,Elements,st){
if( not st=""){
quantitys.Add( c.Convert( st))
}
}
}else{
quantitys.Add(c.Convert(ls.Routing().Batch()))
}
d:=RealToNumber::StandardConverter()
rs:=construct(Reals);
//输液按整天拆,口服按最大批量
value:=max( quantitys,Elements,qu,qu)
a:=guard( d.Convert( qty*10000) div d.Convert( value),0)
difference:=qty*10000-(value*a)
for( i:=a;i>0;i:=i - 1){
rs.Add( value)
}
all:= this.AllQuantity( quantitys,difference,rs,"",ls.Routing().MaterialType())
traverse( all,Elements,qua){
if( qua > 0.0 )
{
random:=random+1
// cc:=OS::GenerateGUIDAsString()
priority:=priority-1
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert( random)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy( this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qua,time,p.UnitPeriod().End(),cc,priority);
updates.Add( ioplannedorder );
}
}
}
else{
if( qty > 0.0 )
{
//cc:=OS::GenerateGUIDAsString()
cc:= ls.RoutingID()+"-"+(conv.Convert(time)).ReplaceAll("00:00:00","")+"-"+num.Convert(1)
ioplannedorder := IOMPSPlannedOrder::CreateSjzsy(this,ls.RoutingID(),p.UnitPeriod().End(),mpsplanid,qty*10000,time,p.UnitPeriod().End(),cc,1);
updates.Add( ioplannedorder );
}}
}}
}
}
// Get the set of old PlannedOrder to be deleted
tobedeleteset := existing.Difference( updates );
traverse( tobedeleteset, Elements, ele )
{
ele.Delete();
}
*]
}
......@@ -15,9 +15,9 @@ Method A_MPSync_ImportProductsSjzsy (
pispspecs := selectset( mpsync, IOPISPSpecification, io, true, true );
this.A_MPSyncProduct_Sjzsy( isoverwritemanualconfig, products );
this.MPSyncProductLevel_MP( isoverwritemanualconfig, productlevels );
this.MPSyncPISPSpecification_MP( isoverwritemanualconfig, pispspecs );
this.A_MPSyncProduct_Sjzsy( false, products );
this.MPSyncProductLevel_MP( false, productlevels );
this.MPSyncPISPSpecification_MP( false, pispspecs );
this.InitializeProductsAfterImport();
......
......@@ -5,8 +5,47 @@ Method DeleteFeedback
TextBody:
[*
// Administration Jul-27-2023 (created)
existing := selectset( this,Feedback.astype(FeedbackPeriodTaskOperation),f,f.Description().LikeUserLocale('内销') or f.Operation().MaterialType()='SF');
traverse( existing,Elements,q,q.DateTime()<this.PeriodParameter_MP().StartOfPlanning()){
//输液
//1、内销全删除
//2、外贸、研发全不删
//口服
//1、内销、外贸、研发全部删除历史及三周外
now:=(Date::ActualDate()).DateTime()
z:=Duration::Days(7)
last:=this.PeriodParameter_MP().StartOfPlanning()-z
syjh := selectset( this,Feedback.astype(FeedbackPeriodTaskOperation),f,f.Operation().ProductType()='输液' and f.Description().LikeUserLocale('内销'));
traverse( syjh,Elements,q,q.DateTime()<=now and q.DateTime()>=last){
q.DateTime(now)
}
//删除当前时间之前的feedback和大于当前开始时间的feedback,输液外贸、研发全不删
sy := selectset( this,Feedback.astype(FeedbackPeriodTaskOperation),f,f.Operation().ProductType()='输液' and f.Description().LikeUserLocale('内销'));
traverse( sy,Elements,q,q.DateTime()<now and q.DateTime()>=this.PeriodParameter_MP().StartOfPlanning()){
q.Delete()
}
h:=Duration::Days(21)
kf := selectset( this,Feedback.astype(FeedbackPeriodTaskOperation),f,f.Operation().ProductType()='口服');
traverse( kf,Elements,q,q.DateTime()<this.PeriodParameter_MP().StartOfPlanning() and q.DateTime()>(this.PeriodParameter_MP().StartOfPlanning()+h)){
q.Delete()
}
......
......@@ -23,10 +23,10 @@ Method InitializeProductsAfterImport0
}
// This will sort products level
this.SortProductLevel( attribute( ProductLevel_MP, LevelForExcel ), true );
//this.SortProductLevel( attribute( ProductLevel_MP, LevelForExcel ), true );
//This will sort units to display them in the correct order in product planning Gantt chart.
this.SortRootProduct( attribute( Product_MP, DisplayIndexForExcel ), true );
this.SortRootProduct( attribute( Product_MP,DisplayIndexForExcel ), true );
product:=selectsortedset( this,Product_MP,p,p.ID());
......
......@@ -15,6 +15,8 @@ Method GetProductID () declarative as String
version:= p.ID()
}
......
Quintiq file version 2.0
#parent: #root
Attribute SCALE
{
#keys: '3[413182.1.1796856819][413182.1.1796856818][413182.1.1796856820]'
ValueType: Real
}
Quintiq file version 2.0
#parent: #root
Attribute DateTime
{
#keys: '3[413182.1.1824561486][413182.1.1824561485][413182.1.1824561487]'
ValueType: DateTime
}
Quintiq file version 2.0
#parent: #root
Attribute ID
{
#keys: '3[413182.1.1824561307][413182.1.1824561306][413182.1.1824561308]'
ValueType: String
}
Quintiq file version 2.0
#parent: #root
Attribute OperationID
{
#keys: '3[413182.1.1824561366][413182.1.1824561365][413182.1.1824561367]'
ValueType: String
}
Quintiq file version 2.0
#parent: #root
Attribute Quantity
{
#keys: '3[413182.1.1824561426][413182.1.1824561425][413182.1.1824561427]'
ValueType: Real
}
Quintiq file version 2.0
#root
#parent: #DomainModel
Type Warehouse
{
#keys: '5[413182.1.1824597094][413182.1.1824597092][0.0.0][413182.1.1824597093][413182.1.1824597095]'
BaseType: Object
StructuredName: 'Warehouses'
}
......@@ -81,8 +81,8 @@ Component mbMainMenu #extension
]
}
Component MenuIMPORT { #keys: '[413182.1.216540432]' BaseType: 'Menu' Properties: [ Text: 'IMPORT' ] }
Component MenuDELETE { #keys: '[413182.1.216680684]' BaseType: 'Menu' Properties: [ Text: 'DELETE' ] }
Component MenuEXPORT { #keys: '[413182.1.216680736]' BaseType: 'Menu' Properties: [ Text: 'EXPORT' ] }
Component MenuDELETE { #keys: '[413182.1.216680684]' BaseType: 'Menu' Properties: [ Text: 'DELETE' Visible: false ] }
Component MenuEXPORT { #keys: '[413182.1.216680736]' BaseType: 'Menu' Properties: [ Text: 'EXPORT' Visible: false ] }
]
Properties:
[
......
......@@ -5,7 +5,7 @@ Project id:MacroPlanner
ProjectProperties
{
ApplicationComponentName: 'ApplicationLibMacroPlanner'
BuildVersion: '2023.1.0.2'
BuildVersion: '2023.1.0.3'
Description: 'DELMIA Quintiq Macro Planner'
ProjectKind: 'DesktopClient'
QuintiqVersion: '6.4.1.0 , build 258128'
......
......@@ -13,11 +13,6 @@ Component ContextMenuFinances #extension
}
Component MenuUnitCosts #extension
{
Properties:
[
Title: 'Unit Costs'
Visible: false
]
}
Component MenuStockingPointCosts #extension
{
......
......@@ -10,7 +10,7 @@ Component ContextMenuProcesses #extension
{
Properties:
[
Visible: false
Visible: true
]
}
Component MenuCampaignsAndTransitions #extension
......
Quintiq file version 2.0
Component ServerInfo #extension
{
Properties:
[
Visible: false
]
}
Quintiq file version 2.0
Component abgStandardGroup #extension
{
Children:
[
#child: pnlStandardInformation4
]
}
Quintiq file version 2.0
Component applicationFixedPageActionBarPageDef #extension
{
Children:
[
#child: abgStandardGroup
]
}
Quintiq file version 2.0
Component pnlStandardInformation4 #extension
{
Children:
[
#child: ServerInfo
]
}
......@@ -14,6 +14,7 @@ OrphanComponent ApplicationMacroPlanner #extension
#child: ActionBarPageSales
#child: ActionBarPageScenarioComparison
#child: ActionBarPageScenarioAnalysis
#child: applicationFixedPageActionBarPageDef
]
}
Component ExportPlanHolder
......
Quintiq file version 2.0
Component List187
{
#keys: '[413182.1.1741027302]'
BaseType: 'WebList'
Children:
[
Component DataExtractor768
{
#keys: '[413182.1.1741027303]'
BaseType: 'WebDataExtractor'
Properties:
[
Source: 'MacroPlan'
Taborder: 0
Transformation: 'Product_MP'
]
}
#child: listActionBarPage673
Component DataSetLevel521
{
#keys: '[413182.1.1741027309]'
BaseType: 'WebDataSetLevel'
Children:
[
#child: listContextMenu850
]
Properties:
[
Columns: '[{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ID","title":"ID","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ID"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"IsProductCategory","title":"IsProductCategory","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"IsProductCategory"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Name","title":"Name","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"Name"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ParentID","title":"ParentID","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"ParentID"}}]'
ContextMenu: 'listContextMenu850'
Taborder: 2
]
}
]
Properties:
[
Taborder: 0
]
}
Quintiq file version 2.0
Component listActionBarPage673
{
#keys: '[413182.1.1741027305]'
BaseType: 'listActionBarPage'
Properties:
[
Taborder: 1
]
}
Quintiq file version 2.0
Component listContextMenu850
{
#keys: '[413182.1.1741027311]'
BaseType: 'listContextMenu'
Properties:
[
Taborder: 0
]
}
Quintiq file version 2.0
#root
#parent: MacroPlannerWebApp
OrphanComponent Form172
{
#keys: '[413182.1.1741027281]'
BaseType: 'WebForm'
Children:
[
#child: List187
]
}
Quintiq file version 2.0
Component ListProduct id:ListProduct_844 #extension
{
Children:
[
Component DataSetLevelRootProduct #extension
{
Properties:
[
Columns: '[{"attribute":{"classtype":"WebApiDefinitionAttributeAllConstraint","columnid":"All constraints","title":"All constraints","subtotals":"","tooltip":"","width":-1,"display":"shown"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"Name","title":"Name","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"Name"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"UnitOfMeasureName","title":"UoM","subtotals":"","tooltip":"","width":-1,"display":"shown","editable":false,"attribute":"UnitOfMeasureName"}},{"attribute":{"classtype":"WebApiDefinitionAttributeDataMember","columnid":"ID","title":"ID","subtotals":"","tooltip":"","width":-1,"display":"shown","attribute":"ID"}}]'
]
}
]
}
Quintiq file version 2.0
Component PanelList #extension
{
Children:
[
#child: ListProduct_844
]
}
Quintiq file version 2.0
#root
#parent: LibMacroPlannerWebUI
OrphanComponent FormProducts #extension
{
Children:
[
#child: PanelList
]
}
......@@ -5,7 +5,7 @@ Project id:MacroPlannerWebApp
ProjectProperties
{
ApplicationComponentName: 'ApplicationMacroPlanner'
BuildVersion: '2023.1.0.216'
BuildVersion: '2023.1.0.229'
Description: 'Quintiq Macro Planner'
ProjectKind: 'WebClient'
QuintiqVersion: '6.4.1.0 , build 258128'
......
component=submodel
kind=Quintiq Metadata File
name=MacroPlanner
version.component=2023.1.0.1423
version.component=2023.1.0.1567
version.fileformat=2
version.quintiq=6.4.1.0 , build 258128
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment