|
@@ -27,7 +27,7 @@
|
|
|
</span>
|
|
|
<span>
|
|
|
并发参数:
|
|
|
- <span style="color:black;">{{_Concurrency}}</span>
|
|
|
+ <span style="color:black;">{{batchConcurrency}}</span>
|
|
|
</span>
|
|
|
<span>
|
|
|
并发请求:
|
|
@@ -113,7 +113,7 @@ export default {
|
|
|
startProcessTime: null, // 开始处理的时间
|
|
|
endProcessTime: null, // 结束处理的时间
|
|
|
processSpeed: 0, // 处理的速度:个/秒
|
|
|
- _Concurrency: 0,
|
|
|
+ batchConcurrency: 0,
|
|
|
faceppConcurrencyErrorNumPerMinute: 0 // 报警频率
|
|
|
};
|
|
|
},
|
|
@@ -174,7 +174,7 @@ export default {
|
|
|
CONCURRENCY--;
|
|
|
}
|
|
|
|
|
|
- this._Concurrency = CONCURRENCY;
|
|
|
+ this.batchConcurrency = CONCURRENCY;
|
|
|
|
|
|
async.parallelLimit(taskQueue100, CONCURRENCY, (err, results) => {
|
|
|
if (err) {
|
|
@@ -222,11 +222,20 @@ export default {
|
|
|
}
|
|
|
|
|
|
//生成新名称
|
|
|
+ let serverPhotoPath = null;
|
|
|
const upyunPhotoPath = (() => {
|
|
|
const md5Hash = CryptoJS.MD5(
|
|
|
Base64.encode(identityNumber + new Date().getTime())
|
|
|
).toString();
|
|
|
- return rootOrgId + "/" + identityNumber + "/" + md5Hash + fileSuffix;
|
|
|
+ serverPhotoPath = md5Hash + fileSuffix;
|
|
|
+ return (
|
|
|
+ rootOrgId +
|
|
|
+ "/" +
|
|
|
+ encodeURIComponent(identityNumber) +
|
|
|
+ "/" +
|
|
|
+ md5Hash +
|
|
|
+ fileSuffix
|
|
|
+ );
|
|
|
})();
|
|
|
|
|
|
// 核心流程:
|
|
@@ -238,13 +247,11 @@ export default {
|
|
|
// 6. 根据以上信息,保存到服务器
|
|
|
// 每一步出错都会保存到错误日志
|
|
|
try {
|
|
|
+ // 不用Promise.all的原因是每一步失败就不用进行下一步了
|
|
|
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);
|
|
|
+ this.faceSetToken = await this.getFaceSetToken();
|
|
|
+ let faceCount = await this.addFaceToSet(this.faceSetToken, faceToken);
|
|
|
|
|
|
await this.saveImageToUpyun({ upyunPhotoPath, photoFile });
|
|
|
const photoInfo = {
|
|
@@ -253,7 +260,8 @@ export default {
|
|
|
faceToken: faceToken,
|
|
|
studentPhotoPath: studentPhotoPath,
|
|
|
rootOrgId: rootOrgId,
|
|
|
- upyunPhotoPath
|
|
|
+ faceCount,
|
|
|
+ photoName: serverPhotoPath
|
|
|
};
|
|
|
await this.saveStudentFaceInfoByPut(photoInfo);
|
|
|
this.finishOnePhotoSuccess("处理成功", studentPhotoPath);
|
|
@@ -266,15 +274,15 @@ export default {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
this.$http
|
|
|
.get(
|
|
|
- "/api/ecs_core/studentFaceInfo/identityNumber?orgId=" +
|
|
|
+ "/api/ecs_core/student/getStudentInfo?orgId=" +
|
|
|
rootOrgId +
|
|
|
"&identityNumber=" +
|
|
|
identityNumber
|
|
|
)
|
|
|
.then(res => {
|
|
|
var studentFaceInfo = res.data;
|
|
|
- if (studentFaceInfo.student && studentFaceInfo.student.id) {
|
|
|
- resolve(studentFaceInfo.student.id);
|
|
|
+ if (studentFaceInfo && studentFaceInfo.id) {
|
|
|
+ resolve(studentFaceInfo.id);
|
|
|
} else {
|
|
|
reject("查询身份证不存在");
|
|
|
}
|
|
@@ -308,7 +316,25 @@ export default {
|
|
|
},
|
|
|
//获取faceSetToken
|
|
|
async getFaceSetToken() {
|
|
|
- return window.DB.queryFaceSet();
|
|
|
+ if (this.faceSetToken) {
|
|
|
+ return this.faceSetToken;
|
|
|
+ } else {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$http
|
|
|
+ .get("/api/ecs_core/faceset/getUsableFacesetList")
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.length < 1) {
|
|
|
+ reject("获取facesetToken失败: 没有可用的facesetToken");
|
|
|
+ } else {
|
|
|
+ resolve(res.data[0].facesetToken);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ reject("获取facesetToken失败: 接口出错");
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
//faceToken加入faceSetToken
|
|
|
async addFaceToSet(faceset_token, face_token) {
|
|
@@ -336,18 +362,9 @@ export default {
|
|
|
);
|
|
|
}
|
|
|
if (res.data.face_count > 8000) {
|
|
|
- window.DB.updateFaceSet(faceset_token, res.data.face_count).then(
|
|
|
- () => {
|
|
|
- this.faceSetToken = undefined;
|
|
|
- resolve();
|
|
|
- },
|
|
|
- err => {
|
|
|
- reject(err);
|
|
|
- }
|
|
|
- );
|
|
|
- } else {
|
|
|
- resolve();
|
|
|
+ this.faceSetToken = undefined;
|
|
|
}
|
|
|
+ resolve(res.data.face_added);
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.log(err);
|
|
@@ -386,15 +403,18 @@ export default {
|
|
|
studentId,
|
|
|
faceSetToken,
|
|
|
faceToken,
|
|
|
- upyunPhotoPath
|
|
|
+ faceCount,
|
|
|
+ photoName
|
|
|
}) {
|
|
|
return this.$http
|
|
|
- .put("/api/ecs_core/studentFaceInfo", {
|
|
|
+ .post("/api/ecs_core/faceset/saveStudentFace", {
|
|
|
rootOrgId,
|
|
|
studentId,
|
|
|
- faceSetToken,
|
|
|
+ facesetToken: faceSetToken,
|
|
|
faceToken,
|
|
|
- photoPath: upyunPhotoPath
|
|
|
+ faceCount,
|
|
|
+ photoName,
|
|
|
+ operator: "客户端工具上传-" + localStorage.getItem("userName")
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.log(err);
|