服务器上的文件数量很多,在扫描过程中显示状态R,B和F
file1
file2
file3
file3
file5
file6
file7
file8
file9
file10
R表示就绪,B表示繁忙,F表示失败。
获取文件1的状态(如果为R),则将打印“我正在下载”,然后检查下一个文件2的状态。如果下一个file2处于B状态,则将等待2分钟,然后一次又一次(间隔2分钟)检查file2的状态,直到状态更改为R或F。一旦更改为R,将打印“我正在下载”,如果状态为F,则简单地移至下一个文件3。我们将以这种方式对所有十个文件执行此操作。
我正在尝试但无法完全实现。
task findcomp {
doLast {
String gId = getgId(User, Password, gName)
JSONArray prods = getIdList(User, Password, gId)
mkdir "workspace/test"
for (int i = 0; i < prods.size(); i++) {
String name = prods.getJSONObject(i).get("name")
String prodId = prods.getJSONObject(i).get("id")
String dest = "workspace/test/${name}.csv"
if (name.matches("$base(.*)")) {
String status = prods.getJSONObject(i).get("status")
def val = status
print val
if ( "$val" == "F" ) {
move to next file } else if ("$val" == "B"){
wait for 2 minutes
go and check same file status and take action as per status //Let suppose file2 status is B then it should wait for 2 minutes and check again the status of same file2 till it changes to R anf F.Once R then will print "I am downloading the file from server" and if F then go to next file
}
print "I am downloading the file from server"
}
}
}
}
}