|
@@ -173,20 +173,14 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
var tDegree = Double(0);
|
|
var tDegree = Double(0);
|
|
var tCount = Int(0)
|
|
var tCount = Int(0)
|
|
var fileIndex = 0
|
|
var fileIndex = 0
|
|
|
|
+ var compareIndex = 0;
|
|
|
|
+ var convertFinished = false;
|
|
|
|
|
|
// 用 Block 递归调用形式,确保转档单任务执行
|
|
// 用 Block 递归调用形式,确保转档单任务执行
|
|
var convertFileBlock = { (files:[String]) in }
|
|
var convertFileBlock = { (files:[String]) in }
|
|
convertFileBlock = { (files:[String]) in
|
|
convertFileBlock = { (files:[String]) in
|
|
if (fileIndex >= files.count) {
|
|
if (fileIndex >= files.count) {
|
|
- //所有任务已经执行完成
|
|
|
|
- TestDegreeManager.shared().set(((tCount != 0) ? tDegree/Double(tCount) : 0.0),
|
|
|
|
- fileType: self.fileType(),
|
|
|
|
- type: self.type())
|
|
|
|
-
|
|
|
|
- self._status = .Finished
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- complention(self, self.reportString);
|
|
|
|
- }
|
|
|
|
|
|
+ convertFinished = true;
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -203,18 +197,40 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
// let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
// let checkPath = NSString(string: checkDirectory).appendingPathComponent(fName+"."+_extention)
|
|
|
|
|
|
|
|
|
|
- self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】开始转换文件 \"\(fName)\"\n",
|
|
|
|
- attributes:[.foregroundColor : NSColor.blue]))
|
|
|
|
|
|
+// self.reportString?.append(NSMutableAttributedString.init(string: "【\(String(self.fileType())) - \(self.name())】开始转换文件 \"\(fName)\"\n",
|
|
|
|
+// attributes:[.foregroundColor : NSColor.blue]))
|
|
// ...
|
|
// ...
|
|
// 执行异步转换过程
|
|
// 执行异步转换过程
|
|
self.process(originPath, resultPath: resultPath) { status in
|
|
self.process(originPath, resultPath: resultPath) { status in
|
|
- self.compareResult(fileName, resultPath: resultPath, status: status, needCompare: needCompare) { degree in
|
|
|
|
- autoreleasepool {
|
|
|
|
- fileIndex += 1;
|
|
|
|
- convertFileBlock(files)
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ DispatchQueue.global().async {
|
|
|
|
+ Thread.sleep(forTimeInterval: 0.3)
|
|
|
|
+ fileIndex += 1;
|
|
|
|
+ convertFileBlock(files)
|
|
|
|
+
|
|
|
|
+ self.compareResult(fileName, resultPath: resultPath, status: status, needCompare: needCompare) { degree in
|
|
|
|
+ autoreleasepool {
|
|
|
|
+ if (degree >= 0.0) {
|
|
|
|
+ tDegree += degree;
|
|
|
|
+ tCount += 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ compareIndex += 1;
|
|
|
|
+ if (convertFinished && compareIndex >= files.count) {
|
|
|
|
+ //所有任务已经执行完成
|
|
|
|
+ TestDegreeManager.shared().set(((tCount != 0) ? tDegree/Double(tCount) : 0.0),
|
|
|
|
+ fileType: self.fileType(),
|
|
|
|
+ type: self.type())
|
|
|
|
+
|
|
|
|
+ self._status = .Finished
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ complention(self, self.reportString);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 启动第0号任务
|
|
// 启动第0号任务
|
|
@@ -255,6 +271,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
}
|
|
}
|
|
|
|
|
|
func compareResult(_ fileName:String, resultPath:String, status:Int, needCompare:Bool, complention:@escaping (_ degree:Double) -> ()) {
|
|
func compareResult(_ fileName:String, resultPath:String, status:Int, needCompare:Bool, complention:@escaping (_ degree:Double) -> ()) {
|
|
|
|
+ NSLog("开始识别:\(fileName)");
|
|
let checkDirectory = self.checkFileDirectory()
|
|
let checkDirectory = self.checkFileDirectory()
|
|
// let originDirectory = self.originFileDirectory()
|
|
// let originDirectory = self.originFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
let resultDirectory = self.resultFileDirectory()
|
|
@@ -302,6 +319,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
autoreleasepool {
|
|
autoreleasepool {
|
|
// 执行下一个文件转档
|
|
// 执行下一个文件转档
|
|
complention(subDegree)
|
|
complention(subDegree)
|
|
|
|
+ NSLog("结束识别:\(fileName)");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// }
|
|
// }
|
|
@@ -449,6 +467,7 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
autoreleasepool {
|
|
autoreleasepool {
|
|
// 执行下一个文件转档
|
|
// 执行下一个文件转档
|
|
|
|
+ NSLog("结束识别:\(fileName)");
|
|
complention(0)
|
|
complention(0)
|
|
}
|
|
}
|
|
}
|
|
}
|