| | |
| | | Quintiq file version 2.0 |
| | | #parent: #root |
| | | Method GenerateColumn ( |
| | | Dates periods, |
| | | String timeunit, |
| | | Date starttime, |
| | | Date endtime |
| | | Dates periods |
| | | ) |
| | | { |
| | | TextBody: |
| | | [* |
| | | // 甄兰鸽 Jun-25-2024 (created) |
| | | mindate := min( periods, Elements, period, period ); |
| | | maxdate := max( periods, Elements, period, period ); |
| | | //查询日期返回需要在计划日期之内 |
| | | if( starttime < mindate and endtime > maxdate ){ |
| | | if( starttime < mindate ){ |
| | | starttime := mindate; |
| | | weekstart := periods.Element( 0 ); |
| | | |
| | | monthstart := periods.Element( 0 ); |
| | | traverse( periods, Elements, periodtime ){ |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | |
| | | this.Column( relnew, ColumnName := periodname, StartDate := periodtime, EndDate := periodtime, TimeUnit := Translations::MP_GlobalParameters_Day() ); |
| | | |
| | | weekend := ( weekstart + Duration::Days( 6 ) ).Date(); |
| | | if( ( weekend.Year() <> periodtime.Year() and weekend.Month() > 1 ) or ( abs( weekstart.Week() - periodtime.Week() ) > 1 and weekend.Year() = periodtime.Year() ) ){ |
| | | weekstart := periodtime; |
| | | } |
| | | if( endtime > maxdate ){ |
| | | endtime := maxdate; |
| | | if( periodtime = weekstart ){ |
| | | weekperiodname := weekstart.Format( "M2/D2/Y" ); |
| | | this.Column( relnew, ColumnName := weekperiodname, StartDate := weekstart, EndDate := ( weekstart.StartOfNextWeek() - Duration::Days( 1 ) ).Date(), TimeUnit := Translations::MP_GlobalParameters_Week() ); |
| | | |
| | | } |
| | | if( timeunit = Translations::MP_GlobalParameters_Day() ){ |
| | | for( start := starttime; start <= endtime; start := start.DateTime().StartOfNextDay().Date() ){ |
| | | periodname := start.Format( "M2/D2/Y" ); |
| | | if( not exists( this, Column, column, column.StartDate() = start ) ){ |
| | | this.Column( relnew, ColumnName := periodname, StartDate := start, EndDate := start, TimeUnit := Translations::MP_GlobalParameters_Day() ); |
| | | } |
| | | } |
| | | }else if( timeunit = Translations::MP_GlobalParameters_Week() ){ |
| | | // weekstartstr := ' KW'; |
| | | for( start := starttime; start <= endtime; start := start.StartOfNextWeek() ){ |
| | | weekend := ( start.StartOfNextWeek() - Duration::Days( 1 ) ).Date();//.Concat( weekstartstr.Concat( weekend.Week().Format( 'N(LPad0(2))' ) ) ) |
| | | |
| | | this.Column( relnew, ColumnName := weekend.Format( "M2/D2/Y" ), StartDate := start, EndDate := weekend, TimeUnit := Translations::MP_GlobalParameters_Week() ); |
| | | } |
| | | }else if( timeunit = Translations::MP_GlobalParameters_Month() ){ |
| | | for( start := starttime; start <= endtime; start := start.StartOfNextMonth() ){ |
| | | monthend := ( start.StartOfNextMonth() - Duration::Days( 1 ) ).Date();//.Concat( ' ' ).Concat( monthend.Format( "MM", us_locale ).Concat( '/').Concat( [String]monthend.Month() ).Concat( '月' ) ) |
| | | // us_locale := Locale::Construct( 'en_us' ); |
| | | this.Column( relnew, ColumnName := monthend.Format( "M2/D2/Y" ), StartDate := start, EndDate := monthend, TimeUnit := Translations::MP_GlobalParameters_Month() ); |
| | | } |
| | | if( ( monthstart.Year() <> periodtime.Year() and abs( monthstart.Month() - periodtime.Month() ) <> 11 ) or ( abs( monthstart.Month() - periodtime.Month() ) > 1 and monthstart.Year() = periodtime.Year() ) ){ |
| | | monthstart := periodtime; |
| | | } |
| | | if( periodtime = monthstart ){ |
| | | monthperiodname := monthstart.Format( "M2/D2/Y" ); |
| | | enddate := ( monthstart.StartOfNextMonth() - Duration::Days( 1 ) ).Date(); |
| | | this.Column( relnew, ColumnName := monthperiodname, StartDate := monthstart, EndDate := enddate, TimeUnit := Translations::MP_GlobalParameters_Month() ); |
| | | |
| | | } |
| | | weekstart := periodtime.StartOfNextWeek(); |
| | | monthstart := periodtime.StartOfNextMonth(); |
| | | } |
| | | //weekstart := periods.Element( 0 ); |
| | | //monthstart := periods.Element( 0 ); |
| | | //traverse( periods, Elements, periodtime ){ |
| | | // periodname := periodtime.Format( "M2/D2/Y" ); |
| | | // |
| | | // this.Column( relnew, Name := periodname, StartDate := periodtime, EndDate := periodtime, TimeUnit := Translations::MP_GlobalParameters_Day() ); |
| | | // |
| | | // if( periodtime = weekstart ){ |
| | | // weekperiodname := weekstart.Format( "M2/D2/Y" ); |
| | | // this.Column( relnew, Name := weekperiodname, StartDate := weekstart, EndDate := ( weekstart + Duration::Days( 6 ) ).Date(), TimeUnit := Translations::MP_GlobalParameters_Week() ); |
| | | // weekstart := ( weekstart + Duration::Days( 7 ) ).Date(); |
| | | // } |
| | | // if( periodtime = monthstart ){ |
| | | // monthperiodname := monthstart.Format( "M2/D2/Y" ); |
| | | // enddate := ( monthstart.StartOfNextMonth() - Duration::Days( 1 ) ).Date(); |
| | | // this.Column( relnew, Name := monthperiodname, StartDate := monthstart, EndDate := enddate, TimeUnit := Translations::MP_GlobalParameters_Month() ); |
| | | // monthstart := monthstart.StartOfNextMonth(); |
| | | // } |
| | | //} |
| | | *] |
| | | } |