lazhen
2024-12-18 32f0336643e045587fca0b513564ee68f6f801ab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Quintiq file version 2.0
#parent: #root
Method InitializeDate (
  LibCal_SubscriberEventTable table,
  DateTime starttime,
  DateTime endtime,
  String desc
)
{
  TextBody:
  [*
    // 甄兰鸽 May-29-2024 (created)
    startTime         := starttime;
    nextweektime      := starttime;
    nextmonthtime     := starttime;
    while( startTime < endtime ){
    //for(  startTime := starttime; startTime < endtime; startTime := startTime.StartOfNextDay() ){
      //天
      daytime         := this.GetTimeByTimeUnit( starttime, startTime, Translations::MP_GlobalParameters_Day() );
      daycolumn       := table.GetColumnByTimeUnit( table, daytime, Translations::MP_GlobalParameters_Day() );
      daycell         := daycolumn.GetCellByTimeUnit( this, desc );
      if( table.MaxDayDate().IsInfinite() ){
        table.MaxDayDate( daytime );
      }else{
        table.MaxDayDate( ifexpr( table.MaxDayDate() < daytime, daytime, table.MaxDayDate() ) );
      }
      if( table.MinDayDate().IsInfinite() ){
        table.MinDayDate( daytime );
      }else{
        table.MinDayDate( ifexpr( table.MinDayDate() > daytime, daytime, table.MinDayDate() ) );
      }
      
      dayvalue        := [Real]daycell.Value();
      if( startTime.StartOfNextDay() > endtime ){
        duration      := endtime - startTime;
        dayvalue      := dayvalue + duration.HoursAsReal();
        daycell.Period( relnew, Start := startTime.Format( 'M/D/Y H:m' ), End := endtime.Format( 'M/D/Y H:m' ) );
      }else{
        duration      := startTime.StartOfNextDay() - startTime;
        dayvalue      := dayvalue + duration.HoursAsReal();
        daycell.Period( relnew, Start := startTime.Format( 'M/D/Y H:m' ), End := startTime.StartOfNextDay().Format( 'M/D/Y H:m' ) );
      }
      daycell.Value( [String]dayvalue );
      //周
      if( nextweektime = startTime ){
        weektime      := this.GetTimeByTimeUnit( starttime, startTime, Translations::MP_GlobalParameters_Week() );
        weekcolumn    := table.GetColumnByTimeUnit( table, weektime, Translations::MP_GlobalParameters_Week() );
        weekcell      := weekcolumn.GetCellByTimeUnit( this, desc );
        if( table.MaxWeekDate().IsInfinite() ){
          table.MaxWeekDate( weektime );
        }else{
          table.MaxWeekDate( ifexpr( table.MaxWeekDate() < weektime, weektime, table.MaxWeekDate() ) );
        }
        if( table.MinWeekDate().IsInfinite() ){
          table.MinWeekDate( weektime );
        }else{
          table.MinWeekDate( ifexpr( table.MinWeekDate() > weektime, weektime, table.MinWeekDate() ) );
        }
        weekvalue     := [Real]weekcell.Value();
        if( startTime.StartOfNextWeek() > endtime ){
          duration    := endtime - startTime;
          weekvalue   := weekvalue + duration.HoursAsReal();
          weekcell.Period( relnew, Start := startTime.Format( 'M/D/Y H:m' ), End := endtime.Format( 'M/D/Y H:m' ) );
        }else{
          duration    := startTime.StartOfNextWeek() - startTime;
          weekvalue   := weekvalue + duration.HoursAsReal();
          weekcell.Period( relnew, Start := startTime.Format( 'M/D/Y H:m' ), End := startTime.StartOfNextWeek().Format( 'M/D/Y H:m' ) );
        }
        weekcell.Value( [String]weekvalue );
        nextweektime := startTime.StartOfNextWeek();
      }
    //  info( '-----------------------------1------------------------', nextmonthtime, startTime, nextweektime );
      //月
      if( nextmonthtime = startTime ){
        monthtime     := this.GetTimeByTimeUnit( starttime, startTime, Translations::MP_GlobalParameters_Month() );
        monthcolumn   := table.GetColumnByTimeUnit( table, monthtime, Translations::MP_GlobalParameters_Month() );
        monthcell     := monthcolumn.GetCellByTimeUnit( this, desc );
        if( table.MaxMonthDate().IsInfinite() ){
          table.MaxMonthDate( monthtime );
        }else{
          table.MaxMonthDate( ifexpr( table.MaxMonthDate() < monthtime, monthtime, table.MaxMonthDate() ) );
        }
        if( table.MinMonthDate().IsInfinite() ){
          table.MinMonthDate( monthtime );
        }else{
          table.MinMonthDate( ifexpr( table.MinMonthDate() > monthtime, monthtime, table.MinMonthDate() ) );
        }
    //    info( nextmonthtime, startTime, monthtime, isnull( monthcolumn ), isnull( monthcell ) );
        monthvalue    := [Real]monthcell.Value();
        if( startTime.StartOfNextMonth() > endtime ){
          duration    := endtime - startTime;
          monthvalue  := monthvalue + duration.HoursAsReal();
          monthcell.Period( relnew, Start := startTime.Format( 'M/D/Y H:m' ), End := endtime.Format( 'M/D/Y H:m' ) );
        }else{
          duration    := startTime.StartOfNextMonth() - startTime;
          monthvalue  := monthvalue + duration.HoursAsReal();
          monthcell.Period( relnew, Start := startTime.Format( 'M/D/Y H:m' ), End := startTime.StartOfNextMonth().Format( 'M/D/Y H:m' ) );
        }
        monthcell.Value( [String]monthvalue );
        nextmonthtime := startTime.StartOfNextMonth();
      }
      startTime := startTime.StartOfNextDay();
    }
  *]
}