Browse Source

修改record senum动态生成 ,修改下载的demo json

ZhangLeo 2 months ago
parent
commit
d69e2924cc
2 changed files with 132 additions and 10 deletions
  1. 116 4
      static/db/downloadDemo.json
  2. 16 6
      utils/dataProcessor.uts

+ 116 - 4
static/db/downloadDemo.json

@@ -62,7 +62,7 @@
 							"sizeStr": null,
 							"status": null,
 							"metadata": null,
-							"_id": "d3d4dbad-f97c-4c22-b87d-05e3ced38de3",
+							"_id": "0",
 							"fid": null,
 							"billid": "9349c04f4eb74a2491b0b9246755465a",
 							"filename": "04-17 (278)(公开).JPG",
@@ -91,7 +91,7 @@
 							"sizeStr": null,
 							"status": null,
 							"metadata": null,
-							"_id": "d3d4dbad-f97c-4c22-b87d-05e3ced38de2",
+							"_id": "1",
 							"fid": null,
 							"billid": "9349c04f4eb74a2491b0b9246111a",
 							"filename": "04-17 (278)(公开).JPG",
@@ -120,7 +120,7 @@
 							"sizeStr": null,
 							"status": null,
 							"metadata": null,
-							"_id": "d3d4dbad-f97c-4c22-b87d-05e3ced38de2",
+							"_id": "2",
 							"fid": null,
 							"billid": "9349c04f4eb74a2491b0b9246111a",
 							"filename": "04-17 (278)(公开).JPG",
@@ -174,7 +174,7 @@
 							"sizeStr": null,
 							"status": null,
 							"metadata": null,
-							"_id": "d3d4dbad-f97c-4c22-b87d-05e3ced38de3",
+							"_id": "1",
 							"fid": null,
 							"billid": "9349c04f4eb74a2491b0b9246755465a",
 							"filename": "04-17 (278)(公开).JPG",
@@ -186,6 +186,118 @@
 							"creator_deptname": null,
 							"ts": null
 							
+						},
+						{
+							"url": null,
+							"fileno": null,
+							"pk_filetype": null,
+							"filetype": null,
+							"secret_level": null,
+							"author_name": null,
+							"author_code": null,
+							"author_deptno": null,
+							"author_deptname": null,
+							"makedate": null,
+							"uploadDate": "Sep 18, 2025 10:05:38 AM",
+							"size": 1727989,
+							"sizeStr": null,
+							"status": null,
+							"metadata": null,
+							"_id": "2",
+							"fid": null,
+							"billid": "9349c04f4eb74a2491b0b9246111a",
+							"filename": "04-17 (278)(公开).JPG",
+							"scope": null,
+							"ftype": 0,
+							"creator_name": null,
+							"creator_code": null,
+							"creator_deptcode": null,
+							"creator_deptname": null,
+							"ts": null
+							
+						}
+					],
+					"photoFiles_object": []
+				},
+				{
+					"pk": "d5a3f01e919845bda8f882e46e67e921",
+					"pid": "0228bc10-6d42-4e0c-98a2-486fe9d80d18",
+					"fktempc": "9349c04f4eb74a2491b0b926755465a",
+					"senum": null,
+					"part": "传感器安装",
+					"photoitem": "筒段",
+					"descb": "第一层防晃板对接桁条标准件开口销",
+					"partno": "3",
+					"num": 2,
+					"urlspl": null,
+					"imgname": null,
+					"urlpdt": null,
+					"createtime": "2025-09-18 09:55:46",
+					"createuser": "XXX",
+					"createuserid": "102661fe-ba54-46f1-a09b-958051942796",
+					"updatetime":null,
+					"updateuser": null,
+					"updateuserid": null,
+					"dr": "0",
+					"pk_corp": "800",
+					"photoFiles_example": [
+						{
+							"url": null,
+							"fileno": null,
+							"pk_filetype": null,
+							"filetype": null,
+							"secret_level": null,
+							"author_name": null,
+							"author_code": null,
+							"author_deptno": null,
+							"author_deptname": null,
+							"makedate": null,
+							"uploadDate": "Sep 18, 2025 10:05:38 AM",
+							"size": 1727989,
+							"sizeStr": null,
+							"status": null,
+							"metadata": null,
+							"_id": "0",
+							"fid": null,
+							"billid": "9349c04f4eb74a2491b0b9246755465a",
+							"filename": "04-17 (278)(公开).JPG",
+							"scope": null,
+							"ftype": 0,
+							"creator_name": null,
+							"creator_code": null,
+							"creator_deptcode": null,
+							"creator_deptname": null,
+							"ts": null
+							
+						},
+						{
+							"url": null,
+							"fileno": null,
+							"pk_filetype": null,
+							"filetype": null,
+							"secret_level": null,
+							"author_name": null,
+							"author_code": null,
+							"author_deptno": null,
+							"author_deptname": null,
+							"makedate": null,
+							"uploadDate": "Sep 18, 2025 10:05:38 AM",
+							"size": 1727989,
+							"sizeStr": null,
+							"status": null,
+							"metadata": null,
+							"_id": "1",
+							"fid": null,
+							"billid": "9349c04f4eb74a2491b0b9246111a",
+							"filename": "04-17 (278)(公开).JPG",
+							"scope": null,
+							"ftype": 0,
+							"creator_name": null,
+							"creator_code": null,
+							"creator_deptcode": null,
+							"creator_deptname": null,
+							"ts": null
+							
 						},
 						{
 							"url": null,

+ 16 - 6
utils/dataProcessor.uts

@@ -163,21 +163,31 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 
 													// 使用async/await处理循环中的异步操作
 													const processAllRecords = async () => {
+														// 创建一个Map来跟踪不同photoitem的计数
+														const photoItemCounter: Map<string, number> = new Map();
+														
 														for (var i = 0; i < recordList.length; i++) {
 															// 更新进度
 															processedRecords++;
 															showProgress(processedRecords);
-															
+																
 															const record : MediaRecordData = recordList[i] as MediaRecordData;
 															// 获取各个字段的值
-															const senum = record.senum;
-															const photoitem = record.photoitem;
-															const part = record.part;
+															const photoitem = record.photoitem as string;
+															// 根据photoitem类型统计senum
+															if (!photoItemCounter.has(photoitem)) {
+																photoItemCounter.set(photoitem, 1);
+															} else {
+															const currentCount = photoItemCounter.get(photoitem);
+															photoItemCounter.set(photoitem, (currentCount != null ? currentCount : 0) + 1);
+														}
+														const senum = photoItemCounter.get(photoitem);
+														const finalSenum = senum != null ? senum : 1;
 															const partno = record.partno;
+															const part = record.part;
 															const pk = record.pk;
 															const descb = record.descb;
 															const num = record.num;
-															const urlspl = record.urlspl;
 															const imgname = record.imgname;
 															const urlpdt = record.urlpdt;
 															const createtime = record.createtime;
@@ -261,7 +271,7 @@ export const downloadDataFromAPI = async (productCode : string, callback ?: () =
 															console.log(imagePaths);
 
 															// 使用三目运算符判断,当值为null时直接插入null,否则用单引号括起来
-															var values = `${senum === null ? '1' : `'${senum}'`}, ${photoitem === null ? 'null' : `'${photoitem}'`}, ${data?.['productcode'] === null ? 'null' : `'${data?.['productcode']}'`},${part === null ? 'null' : `'${part}'`},${partno === null ? 'null' : `'${partno}'`},${pk === null ? 'null' : `'${pk}'`},${exampleid === null ? 'null' : `'${exampleid}'`},${descb === null ? 'null' : `'${descb}'`},${num === null ? 0 : num},1,'', ${imagePaths === null ? 'null' : `'${imagePaths}'`},${imgname === null ? 'null' : `'${imgname}'`},${urlpdt === null ? 'null' : `'${urlpdt}'`}, ${createtime === null ? 'null' : `'${createtime}'`}, ${createuser === null ? 'null' : `'${createuser}'`}, ${updatetime === null ? 'null' : `'${updatetime}'`}, ${updateuser === null ? 'null' : `'${updateuser}'`}, ${lastId === null ? 0 : lastId}`;
+															var values = `${finalSenum === null ? '1' : `'${finalSenum}'`}, ${photoitem === null ? 'null' : `'${photoitem}'`}, ${data?.['productcode'] === null ? 'null' : `'${data?.['productcode']}'`},${part === null ? 'null' : `'${part}'`},${partno === null ? 'null' : `'${partno}'`},${pk === null ? 'null' : `'${pk}'`},${exampleid === null ? 'null' : `'${exampleid}'`},${descb === null ? 'null' : `'${descb}'`},${num === null ? 0 : num},1,'', ${imagePaths === null ? 'null' : `'${imagePaths}'`},${imgname === null ? 'null' : `'${imgname}'`},${urlpdt === null ? 'null' : `'${urlpdt}'`}, ${createtime === null ? 'null' : `'${createtime}'`}, ${createuser === null ? 'null' : `'${createuser}'`}, ${updatetime === null ? 'null' : `'${updatetime}'`}, ${updateuser === null ? 'null' : `'${updateuser}'`}, ${lastId === null ? 0 : lastId}`;
 
 															// 只有在所有图片下载完成后才调用saveMediaRecord
 															saveMediaRecord(values);