本帖最后由 pcl_test 于 2016-12-2 08:55 编辑
上班可提早,下班常延迟,在指定时间段内产生跟人数等量的不重复时间点再随机与ID和人名组合
7:30-8:30相差60分钟,60*60-2=3598秒,假设有50人,则每间隔3598/50≈71秒打一次卡- @echo off&setlocal enabledelayedexpansion
- set t=07:30:00
- for /l %%i in (1 1 50) do (
- set r=71
- for /f "tokens=1-3 delims=:" %%a in ("!t!") do (
- set /a h=1%%a-100,m=1%%b-100,s=1%%c-100
- for %%d in (s m h) do (
- set /a "v=%%d,%%d=(%%d+r)%%60,r=(v+r)/60"
- )
- set /a h=100+h,m=100+m,s=100+s
- set t=!h:~-2!:!m:~-2!:!s:~-2!
- echo;!t!
- )
- )
- pause
复制代码
- @echo off
- rem win7及以上系统运行
- for /f "delims=" %%a in ('more +7 "%~f0"') do call set "list=%%list%%%%a;"
- set start=11:30
- set end=12:30
- powershell -c "$list=@{%list%};$len=$list.count;$array=Get-Random (1..$len) -count $len;$a=(New-TimeSpan %start% -end %end%).TotalSeconds;$t=(Get-Date %start%);$r=0;while($r -le ($len-1)){'time=\"{0}\" id=\"{1}\" name=\"{2}\"' -f $t.ToString('yyyy-MM-dd HH:mm:ss'),$array[$r],$list[$array[$r]];$r++;$t=(Get-Date $t).AddSeconds((Get-Random -min ([int](($a-2)/$len/2)) -max ([int](($a-2)/$len))))}"
- pause&exit
- 1='陈一'
- 2='黄二'
- 3='张三'
- 4='李四'
- 5='王五'
- 6='赵六'
- 7='钱七'
- 8='孙八'
- 9='杨九'
- 10='吴十'
复制代码
|