added fabtime shift calendar

This commit is contained in:
Infineon\StieberD
2024-10-03 17:36:01 -07:00
committed by Stieber Daniel (CSC FI SPS MESLEO)
parent 291f050338
commit b443f237a1
7 changed files with 640 additions and 4419 deletions

View File

@ -66,7 +66,7 @@ Return Response OR ''
//----------------------------------------------------------------------------------------------------------------------
Service ExportUsers()
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
Lock hSysLists, ServiceKeyID then
userFileName = '\\10.95.104.24\App_Data\user.csv'
@ -104,28 +104,28 @@ end service
Service GetGroups()
Groups = ''
Sentence = 'SELECT SEC_GROUPS BY GROUP'
rv = Set_Status(0)
RList(Sentence, TARGET_ACTIVELIST$, '', '', '')
If (@List_Active EQ 3) AND (@RecCount GT 0) then
EOF = False$
Loop
Readnext GroupID else EOF = True$
Until EOF EQ True$
Groups := GroupID : @FM
Repeat
end
Groups[-1, 1] = ''
Groups = ''
Sentence = 'SELECT SEC_GROUPS BY GROUP'
rv = Set_Status(0)
RList(Sentence, TARGET_ACTIVELIST$, '', '', '')
If (@List_Active EQ 3) AND (@RecCount GT 0) then
EOF = False$
Loop
Readnext GroupID else EOF = True$
Until EOF EQ True$
Groups := GroupID : @FM
Repeat
end
Groups[-1, 1] = ''
Response = Groups
end service
Service GetMembersInGroup(GroupList)
Members = ''
If GroupList NE '' then
GroupsToSearch = 'GROUPS'
@ -151,200 +151,202 @@ Service GetMembersInGroup(GroupList)
Error_Services('Add', 'GroupList was missing in the ' : Service : ' service.')
end
response = Members
end service
Service GetOnShiftUsersByClass(Class, IncludeNextShift)
DatetimeNow = OConv(SRP_DateTime("Now"), 'DT')
NextShiftTime = OConv(SRP_Datetime('AddHours', Datetime(), 12) , 'DT')
CurrentShift = Lsl_Users_Services('GetShiftByDate', DatetimeNow)
IF IncludeNextShift then
CurrentShift := @VM : Lsl_Users_Services('GetShiftByDate', NextShiftTime)
end
Open 'DICT.LSL_USERS' to DictLSLUsers then
SearchString = ''
SearchString := 'CLASSIFICATION':@VM:Class:@FM
SearchString := 'SHIFT' : @VM : CurrentShift<1,1>: @VM : CurrentShift<1,2>: @VM : CurrentShift<1,3>: @VM : CurrentShift<1,4> :@FM
SearchString := 'ACTIVE' : @VM : True$ : @FM
LSLUsersKeys = ''
Btree.Extract(SearchString, 'LSL_USERS', DictLSLUsers, LSLUsersKeys, '', '')
ErrCode = ''
IF Get_Status(ErrCode) then
ErrorMsg = 'Error in ':Service:' service. Error calling Btree.Extract. Error code ':ErrCode:'.'
end
Response = LSLUsersKeys
end else
ErrorMsg = 'Error in ':Service:' service. Error opening LSL_USERS dictionary.'
end
DatetimeNow = OConv(SRP_DateTime("Now"), 'DT')
NextShiftTime = OConv(SRP_Datetime('AddHours', Datetime(), 12) , 'DT')
CurrentShift = Lsl_Users_Services('GetShiftByDate', DatetimeNow)
IF IncludeNextShift then
CurrentShift := @VM : Lsl_Users_Services('GetShiftByDate', NextShiftTime)
end
Open 'DICT.LSL_USERS' to DictLSLUsers then
SearchString = ''
SearchString := 'CLASSIFICATION':@VM:Class:@FM
SearchString := 'SHIFT'
For each Shift in CurrentShift using @VM setting vPos
SearchString := @VM : Shift
Next Shift
SearchString := @VM : '' : @FM ; // Include office personnel (i.e. no shift assigned)
SearchString := 'ACTIVE' : @VM : True$ : @FM
LSLUsersKeys = ''
Btree.Extract(SearchString, 'LSL_USERS', DictLSLUsers, LSLUsersKeys, '', '')
ErrCode = ''
IF Get_Status(ErrCode) then
ErrorMsg = 'Error in ':Service:' service. Error calling Btree.Extract. Error code ':ErrCode:'.'
end
Response = LSLUsersKeys
end else
ErrorMsg = 'Error in ':Service:' service. Error opening LSL_USERS dictionary.'
end
end service
Service GetShiftByDate(Date, GenerateFlag)
OnShift = ''; *Return Value
if Date EQ '' then
Error_Services('Add', 'Error in LSL_USERS_SERVICES. No Date Supplied.')
return
end
DateConv = Iconv(Date, "DT")
CalStartDate = 20097; *Arbitrary Start Date to base calendar off of. February 6th 2022
DaysSinceStart = SRP_DateTime("DaySpan", CalStartDate, DateConv, 0)
WeeksSinceStart = SRP_Math("FLOOR", DaysSinceStart / 7)
WeekType = ''
/*
There are two different types of week and the pattern goes 1 week is a long week for shift 1 and the next is a long
week for shift 3(The two day shifts)
*/
if SRP_Math("EVEN", WeeksSinceStart) AND WeeksSinceStart GE 1 then
WeekType = 'Long1'
end else
WeekType = 'Long3'
end
WeekDay = SRP_DateTime("DayOfWeek", DateConv)
ShiftTime = SRP_DateTime("Time", DateConv)
IF ShiftTime GE 21600 AND ShiftTime LT 64800 then; //6AM and 6PM
DayOrNight = 'Day'
end else
DayOrNight = 'Night'
end
/*
We set up profiles for what a long 1 week has for shift schedules and what a long 3 week has for shift schedules.
This does not change.
*/
Begin Case
Case WeekType = 'Long1'
Begin Case
Case Weekday EQ SUNDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1
Case DayOrNight EQ 'Night'
OnShift = 2
End Case
Case Weekday EQ MONDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 2
End Case
Case Weekday EQ TUESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 2
End Case
Case Weekday EQ WEDNESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 2
end else
OnShift = 4
end
End Case
Case Weekday EQ THURSDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 4
End Case
Case Weekday EQ FRIDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 4
End Case
Case Weekday EQ SATURDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3
Case DayOrNight EQ 'Night'
OnShift = 4
End Case
End Case
Case WeekType = 'Long3'
Begin Case
Case Weekday EQ SUNDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 4
end else
OnShift = 2
end
End Case
Case Weekday EQ MONDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 2
End Case
Case Weekday EQ TUESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 2
End Case
Case Weekday EQ WEDNESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 2
end else
OnShift = 4
end
End Case
Case Weekday EQ THURSDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 4
End Case
Case Weekday EQ FRIDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F'
Case DayOrNight EQ 'Night'
OnShift = 4
End Case
Case Weekday EQ SATURDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 3
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 4
end else
OnShift = 2
end
End Case
End Case
End Case
Response = OnShift
OnShift = ''; *Return Value
if Date EQ '' then
Error_Services('Add', 'Error in LSL_USERS_SERVICES. No Date Supplied.')
return
end
DateConv = Iconv(Date, "DT")
CalStartDate = 18998; *Arbitrary Start Date to base calendar off of. Jan 5, 2020 Beginning of short shift 1
DaysSinceStart = SRP_DateTime("DaySpan", CalStartDate, DateConv, 0)
WeeksSinceStart = SRP_Math("FLOOR", DaysSinceStart / 7)
WeekType = ''
/*
There are two different types of week and the pattern goes 1 week is a long week for shift 1 and the next is a long
week for shift 3(The two day shifts)
*/
if SRP_Math("EVEN", WeeksSinceStart) AND WeeksSinceStart GE 1 then
WeekType = 'Long1'
end else
WeekType = 'Long3'
end
WeekDay = SRP_DateTime("DayOfWeek", DateConv)
ShiftTime = SRP_DateTime("Time", DateConv)
IF ShiftTime GE 21600 AND ShiftTime LT 64800 then; //6AM and 6PM
DayOrNight = 'Day'
end else
DayOrNight = 'Night'
end
/*
We set up profiles for what a long 1 week has for shift schedules and what a long 3 week has for shift schedules.
This does not change.
*/
Begin Case
Case WeekType = 'Long1'
Begin Case
Case Weekday EQ SUNDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
OnShift = 'B'
End Case
Case Weekday EQ MONDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
OnShift = 'B'
End Case
Case Weekday EQ TUESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
OnShift = 'B'
End Case
Case Weekday EQ WEDNESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 'B'
end else
OnShift = 'D'
end
End Case
Case Weekday EQ THURSDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
OnShift = 'D'
End Case
Case Weekday EQ FRIDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
OnShift = 'D'
End Case
Case Weekday EQ SATURDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
OnShift = 'D'
End Case
End Case
Case WeekType = 'Long3'
Begin Case
Case Weekday EQ SUNDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 'D'
end else
OnShift = 'B'
end
End Case
Case Weekday EQ MONDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
OnShift = 'B'
End Case
Case Weekday EQ TUESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'A'
Case DayOrNight EQ 'Night'
OnShift = 'B'
End Case
Case Weekday EQ WEDNESDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 'B'
end else
OnShift = 'D'
end
End Case
Case Weekday EQ THURSDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
OnShift = 'D'
End Case
Case Weekday EQ FRIDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
OnShift = 'D'
End Case
Case Weekday EQ SATURDAY$
Begin Case
Case DayOrNight EQ 'Day'
OnShift = 'C'
Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then
OnShift = 'D'
end else
OnShift = 'B'
end
End Case
End Case
End Case
Response = OnShift
end service