Procházet zdrojové kódy

增加跳过处理身份证的逻辑

Michael Wang před 6 roky
rodič
revize
34a8142eb5
3 změnil soubory, kde provedl 35 přidání a 9 odebrání
  1. 1 1
      electronStart.js
  2. 3 1
      src/main.js
  3. 31 7
      src/views/index.vue

+ 1 - 1
electronStart.js

@@ -18,7 +18,7 @@ function createWindow() {
   win.loadURL("http://localhost:8080");
 
   // Open the DevTools.
-  win.webContents.openDevTools();
+  // win.webContents.openDevTools();
 
   // Emitted when the window is closed.
   win.on("closed", () => {

+ 3 - 1
src/main.js

@@ -29,7 +29,6 @@ qmInstance.interceptors.request.use(
     }
 
     window.requestInProcessingTotal++;
-    // console.log("后台并发峰值:" + window.requestInProcessingTotal);
 
     return config;
   },
@@ -51,6 +50,9 @@ qmInstance.interceptors.response.use(
     const status = error.response.status;
     if (status != 200) {
       console.log(error);
+      if (error.response.data.error_message) {
+        console.log(error.response.data.error_message);
+      }
     }
 
     // 判断reponse的内容,如果是no login就退出

+ 31 - 7
src/views/index.vue

@@ -12,6 +12,9 @@
             上传照片
           </button>
         </a>
+        <div>
+          <input class="base-id-input" type="text" v-model="baseID" placeholder="不处理小于此数字的身份证照片">
+        </div>
         <div class='progress-div'>
           <div>
             <span>
@@ -89,12 +92,14 @@ export default {
       returnMsgList: [], //返回信息
       successNum: 0, //成功数量
       errorNum: 0, //失败数量
+      skipNum: 0, //跳过数量
       allNum: 0, //总数
       completeShow: false,
-      reqNum: 0,
-      startProcessTime: null,
-      endProcessTime: null,
-      processSpeed: 0
+      baseID: "", // 从大于这个身份证号开始处理
+      reqNum: 0, // 并发请求数
+      startProcessTime: null, // 开始处理的时间
+      endProcessTime: null, // 结束处理的时间
+      processSpeed: 0 // 处理的速度:个/秒
     };
   },
   methods: {
@@ -143,7 +148,7 @@ export default {
     },
     processQueueSingle(taskQueue1000) {
       // 并发处理请求,可在控制台查看请求峰值
-      CONCURRENCY = new Date().getHours() < 6 ? 8 : 5;
+      CONCURRENCY = new Date().getHours() < 6 ? 9 : 7;
       async.parallelLimit(taskQueue1000, CONCURRENCY, (err, results) => {
         if (err) {
           alert(err);
@@ -167,12 +172,18 @@ export default {
       const identityNumber = path
         .basename(studentPhotoPath)
         .replace(fileSuffix, ""); //文件名就是身份证号码
+
+      if (this.lessThanBaseID(identityNumber)) {
+        this.finishOnePhotoSuccess("跳过处理", studentPhotoPath);
+        this.skipNum++;
+        return;
+      }
       const photoFile = fs.readFileSync(studentPhotoPath);
       const rootOrgId = localStorage.getItem("rootOrgId");
       this.reqNum = window.requestInProcessingTotal;
 
       this.processSpeed =
-        (this.successNum + this.errorNum) /
+        (this.successNum + this.errorNum - this.skipNum) /
         (Date.now() - this.startProcessTime);
 
       //生成新名称
@@ -380,6 +391,10 @@ export default {
         msg: msg
       });
       this.successNum++;
+      fs.appendFileSync(
+        path.join(path.dirname(studentPhotoPath), "successPhotos.txt"),
+        path.basename(studentPhotoPath) + ":" + msg + "\n"
+      );
     },
     logout() {
       localStorage.removeItem("rootOrgId");
@@ -388,6 +403,9 @@ export default {
       this.$router.push({
         path: "/login"
       });
+    },
+    lessThanBaseID(identityNumber) {
+      return identityNumber < this.baseID; //字符串比较,从第一个字符比较起
     }
   },
   computed: {
@@ -443,7 +461,7 @@ export default {
 .import-body {
   display: grid;
   height: calc(100vh - 100px);
-  grid-template-rows: 250px 1fr;
+  grid-template-rows: 270px 1fr;
 }
 
 .import-div {
@@ -466,6 +484,12 @@ export default {
   cursor: pointer;
 }
 
+.base-id-input {
+  margin-top: 10px;
+  width: 300px;
+  font-size: 20px;
+}
+
 .progress-div {
   display: flex;
   flex-direction: column;