|
@@ -160,8 +160,9 @@ export default {
|
|
|
this.processQueueSingle(taskQueue);
|
|
|
},
|
|
|
processQueueSingle(taskQueue100) {
|
|
|
- // 并发处理请求,可在控制台查看请求峰值
|
|
|
+ // 并发处理请求
|
|
|
// CONCURRENCY = new Date().getHours() < 6 ? 9 : 5;
|
|
|
+ // 根据并发错误频率来决定下一次多少并发
|
|
|
if (window.faceppConcurrencyErrorNumPerMinute < 7 && CONCURRENCY < 9) {
|
|
|
CONCURRENCY++;
|
|
|
} else {
|
|
@@ -175,7 +176,7 @@ export default {
|
|
|
} else {
|
|
|
console.log(results);
|
|
|
if (this.successNum + this.errorNum < this.allNum) {
|
|
|
- console.log("处理完100张图片了,3秒后继续...");
|
|
|
+ console.log("处理完100张图片了,0.5秒后继续...间隔提供给GC");
|
|
|
const delay = Date.now() - this.startProcessTime < 10000 ? 0 : 500; // 如果有跳过的图标则不等待0.5秒
|
|
|
setTimeout(this.processQueue, delay);
|
|
|
} else {
|
|
@@ -193,6 +194,7 @@ export default {
|
|
|
.basename(studentPhotoPath)
|
|
|
.replace(fileSuffix, ""); //文件名就是身份证号码
|
|
|
|
|
|
+ // 根据用户输入来跳过部分图片
|
|
|
if (this.lessThanBaseID(identityNumber)) {
|
|
|
this.finishOnePhotoSuccess("跳过处理", studentPhotoPath);
|
|
|
this.skipNum++;
|
|
@@ -200,14 +202,17 @@ export default {
|
|
|
}
|
|
|
const photoFile = fs.readFileSync(studentPhotoPath);
|
|
|
const rootOrgId = localStorage.getItem("rootOrgId");
|
|
|
- this.reqNum = window.requestInProcessingTotal;
|
|
|
- this.faceppConcurrencyErrorNum = window.faceppConcurrencyErrorNum;
|
|
|
- this.faceppConcurrencyErrorNumPerMinute =
|
|
|
- window.faceppConcurrencyErrorNumPerMinute;
|
|
|
|
|
|
- this.processSpeed =
|
|
|
- (this.successNum + this.errorNum - this.skipNum) /
|
|
|
- (Date.now() - this.startProcessTime);
|
|
|
+ {
|
|
|
+ // 执行过程中的元信息
|
|
|
+ this.reqNum = window.requestInProcessingTotal;
|
|
|
+ this.faceppConcurrencyErrorNum = window.faceppConcurrencyErrorNum;
|
|
|
+ this.faceppConcurrencyErrorNumPerMinute =
|
|
|
+ window.faceppConcurrencyErrorNumPerMinute;
|
|
|
+ this.processSpeed =
|
|
|
+ (this.successNum + this.errorNum - this.skipNum) /
|
|
|
+ (Date.now() - this.startProcessTime);
|
|
|
+ }
|
|
|
|
|
|
//生成新名称
|
|
|
const upyunPhotoPath = (() => {
|
|
@@ -217,26 +222,32 @@ export default {
|
|
|
return rootOrgId + "/" + identityNumber + "/" + md5Hash + fileSuffix;
|
|
|
})();
|
|
|
|
|
|
+ // 核心流程:
|
|
|
+ // 1. get studentId from ecs
|
|
|
+ // 2. get faceToken from facepp
|
|
|
+ // 3. get faceSetToken from ecs
|
|
|
+ // 4. add faceToken to faceSetToken
|
|
|
+ // 5. save photo to upyun
|
|
|
+ // 6. 根据以上信息,保存到服务器
|
|
|
+ // 每一步出错都会保存到错误日志
|
|
|
try {
|
|
|
- let studentFaceInfo = await this.getStudentInfo(
|
|
|
- rootOrgId,
|
|
|
- identityNumber
|
|
|
- );
|
|
|
+ let studentId = await this.getStudentId(rootOrgId, identityNumber);
|
|
|
let faceToken = await this.detectFace(photoFile);
|
|
|
if (this.faceSetToken == undefined) {
|
|
|
+ // 超过8000会重新获取
|
|
|
this.faceSetToken = await this.getFaceSetToken();
|
|
|
}
|
|
|
await this.addFaceToSet(this.faceSetToken, faceToken);
|
|
|
|
|
|
+ await this.saveImageToUpyun({ upyunPhotoPath, photoFile });
|
|
|
const photoInfo = {
|
|
|
- studentId: studentFaceInfo.student.id,
|
|
|
+ studentId: studentId,
|
|
|
faceSetToken: this.faceSetToken,
|
|
|
faceToken: faceToken,
|
|
|
studentPhotoPath: studentPhotoPath,
|
|
|
rootOrgId: rootOrgId,
|
|
|
upyunPhotoPath
|
|
|
};
|
|
|
- await this.saveImageToUpyun({ upyunPhotoPath, photoFile });
|
|
|
await this.saveStudentFaceInfoByPut(photoInfo);
|
|
|
this.finishOnePhotoSuccess("处理成功", studentPhotoPath);
|
|
|
} catch (err) {
|
|
@@ -244,7 +255,7 @@ export default {
|
|
|
this.finishOnePhotoFail(err, studentPhotoPath);
|
|
|
}
|
|
|
},
|
|
|
- async getStudentInfo(rootOrgId, identityNumber) {
|
|
|
+ async getStudentId(rootOrgId, identityNumber) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
this.$http
|
|
|
.get(
|
|
@@ -256,7 +267,7 @@ export default {
|
|
|
.then(res => {
|
|
|
var studentFaceInfo = res.data;
|
|
|
if (studentFaceInfo.student && studentFaceInfo.student.id) {
|
|
|
- resolve(studentFaceInfo);
|
|
|
+ resolve(studentFaceInfo.student.id);
|
|
|
} else {
|
|
|
reject("查询身份证不存在");
|
|
|
}
|
|
@@ -311,6 +322,12 @@ export default {
|
|
|
// res.data.face_added
|
|
|
// }, res.data.face_count: ${res.data.face_count}`
|
|
|
// );
|
|
|
+ if (res.data.face_added !== 1) {
|
|
|
+ reject(
|
|
|
+ "faceToken加入faceSetToken失败: face_added为" +
|
|
|
+ res.data.face_added
|
|
|
+ );
|
|
|
+ }
|
|
|
if (res.data.face_count > 8000) {
|
|
|
window.DB.updateFaceSet(faceset_token, res.data.face_count).then(
|
|
|
() => {
|