tools_batch_files 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/photoBatch.js +40 -6
package/package.json
CHANGED
package/src/photoBatch.js
CHANGED
@@ -35,10 +35,10 @@ const ZIP_FILES_DIR = "zip";
|
|
35
35
|
const expandedName = ".jpg";
|
36
36
|
|
37
37
|
//并发数量
|
38
|
-
const queueCount =
|
38
|
+
const queueCount = 20;
|
39
39
|
|
40
40
|
//起始任务下标
|
41
|
-
let taskIndex =
|
41
|
+
let taskIndex = 16941;
|
42
42
|
|
43
43
|
const readExcel = (path) => {
|
44
44
|
const workbook = XLSX.readFile(path);
|
@@ -327,10 +327,12 @@ const postData = (dataParams, indexFilePath) => {
|
|
327
327
|
|
328
328
|
logger("等待接口返回结果……");
|
329
329
|
|
330
|
-
return axios.post("http://192.168.102.61:9999/upload/photo", formData, {
|
330
|
+
// return axios.post("http://192.168.102.61:9999/upload/photo", formData, {
|
331
|
+
return axios.post("http://127.0.0.1:9999/upload/photo", formData, {
|
331
332
|
headers: {
|
332
333
|
"Content-Type": "multipart/form-data",
|
333
334
|
},
|
335
|
+
timeout: 60000, // 设置超时时间为 60 秒
|
334
336
|
});
|
335
337
|
};
|
336
338
|
|
@@ -354,11 +356,18 @@ const task = async (row, index) => {
|
|
354
356
|
fileName = row.fileName + expandedName;
|
355
357
|
}
|
356
358
|
|
359
|
+
const getPathStartTime = new Date();
|
357
360
|
// 源图片文件夹路径
|
358
361
|
const originFilePath = findFileInDir(
|
359
362
|
path.join(workDir, ORIGIN_FILE_DIR),
|
360
363
|
fileName
|
361
364
|
);
|
365
|
+
const getPathEndTime = new Date();
|
366
|
+
const timeInSeconds = ((getPathEndTime - getPathStartTime) / 1000).toFixed(2);
|
367
|
+
|
368
|
+
logger(`第${index}条Path路径搜索时间:${timeInSeconds}秒`);
|
369
|
+
logger(`-------------------${new Date()}------------------`);
|
370
|
+
|
362
371
|
console.log("originFilePath:" + originFilePath);
|
363
372
|
console.log("fileName:" + fileName);
|
364
373
|
|
@@ -371,6 +380,7 @@ const task = async (row, index) => {
|
|
371
380
|
const indexFilePath = path.join(workDir, "output", index + "");
|
372
381
|
|
373
382
|
try {
|
383
|
+
const workStartTime = new Date();
|
374
384
|
await fs_asnyc.access(originFilePath, fs_asnyc.constants.F_OK);
|
375
385
|
logFileSize(originFilePath);
|
376
386
|
await PriviewPhoto(indexFilePath, originFilePath, fileName);
|
@@ -386,10 +396,21 @@ const task = async (row, index) => {
|
|
386
396
|
keyword,
|
387
397
|
}
|
388
398
|
);
|
389
|
-
|
390
|
-
|
399
|
+
const workEndTime = new Date();
|
400
|
+
const timeInSeconds = ((workEndTime - workStartTime) / 1000).toFixed(2);
|
401
|
+
|
402
|
+
logger(`第${index}条4090处理总时间:${timeInSeconds}秒`);
|
403
|
+
logger(`-------------------${new Date()}------------------`);
|
391
404
|
|
405
|
+
|
406
|
+
const postStartTime = new Date();
|
392
407
|
const resData = await postData(dataParams, indexFilePath);
|
408
|
+
const postEndTime = new Date();
|
409
|
+
const timeInSeconds1 = ((postEndTime - postStartTime) / 1000).toFixed(2);
|
410
|
+
|
411
|
+
logger(`第${index}条接口处理总时间:${timeInSeconds1}秒`);
|
412
|
+
logger(`-------------------${new Date()}------------------`);
|
413
|
+
|
393
414
|
if (resData.data.code === 200) {
|
394
415
|
logger("请求成功!");
|
395
416
|
logger(resData.data.code);
|
@@ -430,12 +451,25 @@ const transitionExcelToJSON = () => {
|
|
430
451
|
const jsonData = readExcel(excelDir);
|
431
452
|
|
432
453
|
const run = (index) => {
|
454
|
+
logger(
|
455
|
+
`run-------------------------------------第${index}条开始------------------------------------`
|
456
|
+
);
|
457
|
+
const readExcelStartTime = new Date();
|
433
458
|
const row = jsonData[index];
|
459
|
+
|
460
|
+
const readExcelEndTime = new Date();
|
461
|
+
const timeInSeconds = (
|
462
|
+
(readExcelEndTime - readExcelStartTime) /
|
463
|
+
1000
|
464
|
+
).toFixed(2);
|
465
|
+
|
466
|
+
logger(`第${index}条Excel搜索时间:${timeInSeconds}秒`);
|
467
|
+
logger(`-------------------${new Date()}------------------`);
|
434
468
|
if (!row) {
|
435
469
|
return;
|
436
470
|
}
|
437
471
|
logger(
|
438
|
-
`----------------------------------------第${index}
|
472
|
+
`----------------------------------------第${index}条task开始--------------------------------`
|
439
473
|
);
|
440
474
|
logger(`-------------------${new Date()}------------------`);
|
441
475
|
task(row, index)
|