Ver Fonte

根据接口修改

Michael Wang há 6 anos atrás
pai
commit
f134b415b6
6 ficheiros alterados com 91 adições e 52 exclusões
  1. 10 0
      .env.30
  2. 4 0
      .gitignore
  3. 1 0
      package.json
  4. 49 29
      src/views/index.vue
  5. 4 0
      src/views/login.vue
  6. 23 23
      vue.config.js

+ 10 - 0
.env.30

@@ -0,0 +1,10 @@
+NODE_ENV=production
+VUE_APP_ECS_CORE=https://ecs-dev.qmth.com.cn:8878
+VUE_APP_DOMAIN=ecs-dev.qmth.com.cn
+VUE_APP_FACEPP_API_KEY=kEz_MSSjkNuHL3fHhCvv62fXkAo-vobE 
+VUE_APP_FACEPP_API_SECRET=aQMioMGUDShMnQmfM1_H_kPTP2pJva6J
+VUE_APP_UPYUN_OPERATOR=examcloud
+VUE_APP_UPYUN_PASSWORD=examcloud123456
+VUE_APP_UPYUN_SERVER=v0.api.upyun.com
+VUE_APP_UPYUN_BUCKET=exam-cloud-test
+VUE_APP_UPYUN_BUCKETURL=/exam-cloud-test/student_base_photo/

+ 4 - 0
.gitignore

@@ -2,6 +2,10 @@
 node_modules
 /dist
 
+# local env files
+.env.local
+.env.*.local
+
 # Log files
 npm-debug.log*
 yarn-debug.log*

+ 1 - 0
package.json

@@ -7,6 +7,7 @@
     "start:electron": "electron electronStart.js",
     "serve": "vue-cli-service serve --port 8080",
     "buildProd": "vue-cli-service build --mode production",
+    "build30": "vue-cli-service build --mode 30",
     "lint": "vue-cli-service lint"
   },
   "dependencies": {

+ 49 - 29
src/views/index.vue

@@ -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);

+ 4 - 0
src/views/login.vue

@@ -1,6 +1,9 @@
 <template>
   <div class="main_bg">
     <div class="login-main">
+      <div class="env">
+        <div>服务器地址: {{server}}</div>
+      </div>
       <div class="username">
         <input class="comminput" @keyup.enter="login()" type="text" ref="name" id="accountValue" v-model="loginInfo.accountValue" placeholder="账号" />
       </div>
@@ -22,6 +25,7 @@ export default {
     return {
       pending: false,
       errorInfo: "",
+      server: process.env.VUE_APP_DOMAIN,
       loginInfo: {
         rootOrgId: "",
         domain: "",

+ 23 - 23
vue.config.js

@@ -1,6 +1,6 @@
 let proxy = {
   "/api/ecs_core": {
-    target: "http://ecs-dev.qmth.com.cn:8000", //代理跨域转地址,基础信息
+    target: process.env.VUE_APP_ECS_CORE, //代理跨域转地址,基础信息
     changeOrigin: true
   },
   "/facepp/v3": {
@@ -19,30 +19,30 @@ let proxy = {
     changeOrigin: true
   }
 };
-let proxyProd = {
-  "/api/ecs_core": {
-    target: "https://ecs.qmth.com.cn:8878", //代理跨域转地址,基础信息
-    changeOrigin: true
-  },
-  "/facepp/v3": {
-    secure: false,
-    target: "https://api-cn.faceplusplus.com",
-    changeOrigin: true
-  },
-  "/exam-cloud/student_base_photo/": {
-    secure: false,
-    target: "http://v0.api.upyun.com",
-    changeOrigin: true
-  },
-  "/exam-cloud": {
-    secure: false,
-    target: "http://v0.api.upyun.com",
-    changeOrigin: true
-  }
-};
+// let proxyProd = {
+//   "/api/ecs_core": {
+//     target: "https://ecs.qmth.com.cn:8878", //代理跨域转地址,基础信息
+//     changeOrigin: true
+//   },
+//   "/facepp/v3": {
+//     secure: false,
+//     target: "https://api-cn.faceplusplus.com",
+//     changeOrigin: true
+//   },
+//   "/exam-cloud/student_base_photo/": {
+//     secure: false,
+//     target: "http://v0.api.upyun.com",
+//     changeOrigin: true
+//   },
+//   "/exam-cloud": {
+//     secure: false,
+//     target: "http://v0.api.upyun.com",
+//     changeOrigin: true
+//   }
+// };
 
 module.exports = {
   devServer: {
-    proxy: proxyProd
+    proxy: proxy
   }
 };