f_oa_workremind_chkdate.srf 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. $PBExportHeader$f_oa_workremind_chkdate.srf
  2. global type f_oa_workremind_chkdate from function_object
  3. end type
  4. forward prototypes
  5. global function boolean f_oa_workremind_chkdate (string arg_parm, datetime arg_dt)
  6. end prototypes
  7. global function boolean f_oa_workremind_chkdate (string arg_parm, datetime arg_dt);//检查arg_dt是否在约定时间范围内
  8. //类型:
  9. // 一次性
  10. // 如果检查时间与约定时间相差 正负30秒 则视作有效
  11. // 循环
  12. // 如果
  13. //
  14. //
  15. boolean rslt,hasEndDate
  16. date date_st,date_en,date_cur,date_tar
  17. time time_st,time_en,time_cur,time_tar
  18. long second
  19. string WeekList
  20. //long fit_hour=30,fit_minute=5,fit_second=1//修正值 单位:秒
  21. s_oa_workremind_timetype los_time
  22. rslt=false
  23. los_time=f_oa_workremind_releasetime(arg_parm)
  24. date_cur=date(los_time.oncedate)
  25. time_cur=time(los_time.oncetime)
  26. date_tar=date(arg_dt)
  27. time_tar=time(arg_dt)
  28. //==================================
  29. //一次性提醒
  30. //==================================
  31. if los_time.checktype="once"then
  32. if date_tar=date_cur then
  33. second=SecondsAfter(time_tar,time_cur)
  34. if second<=30 and second>=-30 then
  35. rslt=true
  36. end if
  37. end if
  38. goto ext
  39. end if
  40. //=======================
  41. //循环执行提醒
  42. //=======================
  43. //日期部分比较
  44. hasEndDate=false
  45. date_st=date(mid(los_time.startdate,1,pos(los_time.startdate,";")-1))
  46. if mid(los_time.startdate,pos(los_time.startdate,";")+1)="noend"then
  47. else
  48. hasEndDate=true
  49. date_en=date(mid(los_time.startdate,pos(los_time.startdate,";")+1))
  50. end if
  51. //检测是否在日期范围内
  52. if hasEndDate then
  53. if date_tar<date_st and date_tar>date_en then
  54. goto ext
  55. end if
  56. else
  57. if date_tar<date_st then
  58. goto ext
  59. end if
  60. end if
  61. //检查日期是否为间隔时间段内第一个单位时间
  62. long day,baseDay
  63. day=DaysAfter(date_st,date_tar)
  64. if los_time.IntervalType="week" then
  65. baseDay=long(mid(los_time.interval,1,pos(los_time.interval,";")-1))*7
  66. string tmp_week
  67. tmp_week=mid(los_time.interval,pos(los_time.interval,";")+1)
  68. if mid(tmp_week,1,1)="1" then WeekList+="Monday,"
  69. if mid(tmp_week,2,1)="1" then WeekList+="Tuesday,"
  70. if mid(tmp_week,3,1)="1" then WeekList+="Wednesday,"
  71. if mid(tmp_week,4,1)="1" then WeekList+="Thursday,"
  72. if mid(tmp_week,5,1)="1" then WeekList+="Friday,"
  73. if mid(tmp_week,6,1)="1" then WeekList+="Saturday,"
  74. if mid(tmp_week,7,1)="1" then WeekList+="Sunday,"
  75. else
  76. baseDay=long(los_time.interval)
  77. end if
  78. day=mod(day,baseDay)
  79. if los_time.IntervalType="day" then
  80. if baseDay<>1 then
  81. if day<>1 then
  82. goto ext
  83. end if
  84. end if
  85. elseif los_time.IntervalType="week" then
  86. if day>7 or day=0 then
  87. if date_tar<>date_st then
  88. goto ext
  89. end if
  90. end if
  91. //具体星期几
  92. string a
  93. a=string(date_tar,"yyyy-mm-dd")
  94. date b
  95. b=date(a)
  96. string weekName
  97. weekName=DayName(b)
  98. if pos(WeekList,weekName)=0 then
  99. goto ext
  100. end if
  101. end if
  102. //时间部分比较
  103. long baseSecond
  104. if los_time.fretype="once" then
  105. time_cur=time(los_time.fre)
  106. else
  107. baseSecond=long(mid(los_time.fre,1,pos(los_time.fre,";")-1))
  108. string ls_time
  109. ls_time=mid(los_time.fre,pos(los_time.fre,";")+1)
  110. time_st=time(mid(ls_time,1,pos(ls_time,";")-1))
  111. time_en=time(mid(ls_time,pos(ls_time,";")+1))
  112. if los_time.fretype="小时" then
  113. baseSecond=baseSecond*60*60
  114. elseif los_time.fretype="分钟" then
  115. baseSecond=baseSecond*60
  116. elseif los_time.fretype="秒" then
  117. end if
  118. end if
  119. //确定当前时间在执行时间段内
  120. if los_time.fretype="once" then
  121. second=SecondsAfter(time_cur,time_tar)
  122. if second>=0 and second<=5 then
  123. rslt=true
  124. end if
  125. goto ext
  126. else
  127. second=SecondsAfter(time_st,time_tar)
  128. if time_tar<time_st or time_tar>time_en then
  129. goto ext
  130. end if
  131. end if
  132. //判断当前时间是否在第一个单位时间内
  133. long firstBase
  134. if los_time.fretype="小时" then
  135. firstBase=60
  136. elseif los_time.fretype="分钟"then
  137. firstBase=5
  138. elseif los_time.fretype="秒"then
  139. firstBase=1
  140. end if
  141. if mod(second,basesecond)<=firstBase then
  142. if mod(second,basesecond)=0 then
  143. if firstBase<>1 then//非秒情况;
  144. goto ext
  145. elseif second<>1 then//非第一秒
  146. goto ext
  147. end if
  148. end if
  149. rslt=true
  150. goto ext
  151. end if
  152. ext:
  153. return rslt
  154. end function