| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | // @ts-nocheck
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | import { initCenterCache, initCenterCacheByKSPT, initEsModel, initialization } from '../../api/index'; | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | import { dateFormat } from '../utils/tools'; | 
					
						
							|  |  |  |  | import AccountTable from '../database/tables/AccountTable'; | 
					
						
							|  |  |  |  | import MA_MARKRULE from '../constants/MA_MARKRULE'; | 
					
						
							|  |  |  |  | import MA_SYSTEMPARM from '../constants/MA_SYSTEMPARM'; | 
					
						
							|  |  |  |  | import MA_MAP_COLLECT from '../constants/MA_MAP_COLLECT'; | 
					
						
							|  |  |  |  | import MA_MAP_COLLECT_SHAPE from '../constants/MA_MAP_COLLECT_SHAPE'; | 
					
						
							|  |  |  |  | import MA_MAP_ITEMCLASS from '../constants/MA_MAP_ITEMCLASS'; | 
					
						
							|  |  |  |  | import MA_MAP_POINT from '../constants/MA_MAP_POINT'; | 
					
						
							|  |  |  |  | import MA_MAP_POINT_ITEM from '../constants/MA_MAP_POINT_ITEM'; | 
					
						
							|  |  |  |  | import MA_MAP_ROAD from '../constants/MA_MAP_ROAD'; | 
					
						
							|  |  |  |  | import MA_MAP_ROAD_LANE from '../constants/MA_MAP_ROAD_LANE'; | 
					
						
							|  |  |  |  | import MA_MAP_SUBITEM from '../constants/MA_MAP_SUBITEM'; | 
					
						
							|  |  |  |  | import MA_SYSSET from '../constants/MA_SYSSET'; | 
					
						
							|  |  |  |  | import ES_CARINFO from '../constants/ES_CARINFO'; | 
					
						
							|  |  |  |  | import ES_EXAMPOINTDETAIL from '../constants/ES_EXAMPOINTDETAIL'; | 
					
						
							|  |  |  |  | import MA_MARKRULESET from '../constants/MA_MARKRULESET'; | 
					
						
							|  |  |  |  | import MA_CDSBINFO from '../constants/MA_CDSBINFO'; | 
					
						
							|  |  |  |  | import MA_ITEMINFO from '../constants/MA_ITEMINFO'; | 
					
						
							|  |  |  |  | import MA_T_CARPARMSET from '../constants/MA_T_CARPARMSET'; | 
					
						
							|  |  |  |  | import ES_CAR_VIDEO_PARAMETER from '../constants/ES_CAR_VIDEO_PARAMETER'; | 
					
						
							|  |  |  |  | import IpConfigTable from '../constants/IpConfigTable'; | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | import CommonConstants from '../constants/CommonConstants'; | 
					
						
							|  |  |  |  | import DeviceInfoTable from '../constants/DeviceInfoTable'; | 
					
						
							|  |  |  |  | import USER from '../constants/USER'; | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  | import USERLIST from '../constants/USERLIST'; | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | import util from '@ohos.util'; | 
					
						
							| 
									
										
										
										
											2024-07-05 09:34:03 +08:00
										 |  |  |  | import FileModel from '../../pages/judgeSDK/utils/fileModel'; | 
					
						
							| 
									
										
										
										
											2024-08-12 14:46:16 +08:00
										 |  |  |  | import FileUtil from '../../common/utils/File'; | 
					
						
							|  |  |  |  | import { GlobalConfig } from '../../config/index'; | 
					
						
							| 
									
										
										
										
											2024-08-21 18:05:24 +08:00
										 |  |  |  | import prompt from '@ohos.promptAction' | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | // @ts-nocheck
 | 
					
						
							|  |  |  |  | //读表
 | 
					
						
							| 
									
										
										
										
											2024-02-21 13:34:14 +08:00
										 |  |  |  | //参数平台
 | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  | const map = { | 
					
						
							|  |  |  |  |   'MA_MARKRULE': MA_MARKRULE, | 
					
						
							|  |  |  |  |   'MA_SYSTEMPARM': MA_SYSTEMPARM, | 
					
						
							|  |  |  |  |   'MA_MAP_COLLECT': MA_MAP_COLLECT, | 
					
						
							|  |  |  |  |   'MA_MAP_COLLECT_SHAPE': MA_MAP_COLLECT_SHAPE, | 
					
						
							|  |  |  |  |   'MA_MAP_ITEMCLASS': MA_MAP_ITEMCLASS, | 
					
						
							|  |  |  |  |   'MA_MAP_POINT': MA_MAP_POINT, | 
					
						
							|  |  |  |  |   'MA_MAP_POINT_ITEM': MA_MAP_POINT_ITEM, | 
					
						
							|  |  |  |  |   'MA_MAP_ROAD': MA_MAP_ROAD, | 
					
						
							|  |  |  |  |   'MA_MAP_ROAD_LANE': MA_MAP_ROAD_LANE, | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |   'MAP_SUBITEM': MA_MAP_SUBITEM, | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |   'MA_SYSSET': MA_SYSSET, | 
					
						
							|  |  |  |  |   'ES_CARINFO': ES_CARINFO, | 
					
						
							|  |  |  |  |   'ES_EXAMPOINTDETAIL': ES_EXAMPOINTDETAIL, | 
					
						
							|  |  |  |  |   'MA_MARKRULESET': MA_MARKRULESET, | 
					
						
							|  |  |  |  |   'MA_CDSBINFO': MA_CDSBINFO, | 
					
						
							|  |  |  |  |   'MA_ITEMINFO': MA_ITEMINFO, | 
					
						
							|  |  |  |  |   'MA_T_CARPARMSET': MA_T_CARPARMSET, | 
					
						
							|  |  |  |  |   'ES_CAR_VIDEO_PARAMETER': ES_CAR_VIDEO_PARAMETER, | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   'USER': USER, | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |   'USERLIST': USERLIST, | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   'IpConfigTable': IpConfigTable, | 
					
						
							|  |  |  |  |   'DeviceInfoTable': DeviceInfoTable, | 
					
						
							|  |  |  |  |   'CommonConstants': CommonConstants | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | const centerToMap = { | 
					
						
							|  |  |  |  |   'ItemInfo': MA_ITEMINFO, | 
					
						
							|  |  |  |  |   'MarkRule': MA_MARKRULE, | 
					
						
							|  |  |  |  |   'SystemParm': MA_SYSTEMPARM, | 
					
						
							|  |  |  |  |   'mapCollectList': MA_MAP_COLLECT, | 
					
						
							|  |  |  |  |   'mapCollectshapeList': MA_MAP_COLLECT_SHAPE, | 
					
						
							| 
									
										
										
										
											2024-07-03 16:21:56 +08:00
										 |  |  |  |   'Map_Collect': MA_MAP_COLLECT, | 
					
						
							|  |  |  |  |   'Map_Collect_Shape': MA_MAP_COLLECT_SHAPE, | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   'Map_ItemClass': MA_MAP_ITEMCLASS, | 
					
						
							|  |  |  |  |   'Map_Point': MA_MAP_POINT, | 
					
						
							|  |  |  |  |   'Map_Point_Item': MA_MAP_POINT_ITEM, | 
					
						
							|  |  |  |  |   'Map_Road': MA_MAP_ROAD, | 
					
						
							|  |  |  |  |   'Map_Road_Lane': MA_MAP_ROAD_LANE, | 
					
						
							|  |  |  |  |   'Map_SubItem': MA_MAP_SUBITEM, | 
					
						
							|  |  |  |  |   'Sysset': MA_SYSSET, | 
					
						
							|  |  |  |  |   'CarInfo': ES_CARINFO, | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |   // 'ES_EXAMPOINTDETAIL':ES_EXAMPOINTDETAIL,
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   'MarkRuleSet': MA_MARKRULE, | 
					
						
							|  |  |  |  |   'Cdsbinfo': MA_CDSBINFO, | 
					
						
							|  |  |  |  |   'T_CarParmSet': MA_T_CARPARMSET, | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |   // 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER
 | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-02-26 15:01:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | function sqlInsertCommonFn(tableName, resultArr, context?, delFlag = true) { | 
					
						
							|  |  |  |  |   return new Promise((resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |     const accountTable = new AccountTable(() => { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     }, map[tableName], context); | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |     accountTable.getRdbStore(() => { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       accountTable.query('0', async (result) => { | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |         console.log('teststet3',) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         // console.log('表长度',result.length,tableName)
 | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |         if (result.length == 0) { | 
					
						
							| 
									
										
										
										
											2024-08-19 14:54:11 +08:00
										 |  |  |  |           console.log('sqlsqlinsert',resultArr.length) | 
					
						
							|  |  |  |  |           if(resultArr.length==0){ | 
					
						
							|  |  |  |  |             resolve(false) | 
					
						
							|  |  |  |  |             return | 
					
						
							|  |  |  |  |           } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |           let INSERT_SQL = "INSERT INTO " + tableName | 
					
						
							|  |  |  |  |             + " (" + map[tableName].ACCOUNT_TABLE.columns.toString() + ") VALUES " | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |           resultArr.map((data, i) => { | 
					
						
							|  |  |  |  |             data.id = `${i}` | 
					
						
							|  |  |  |  |             let str = '(' | 
					
						
							|  |  |  |  |             map[tableName].ACCOUNT_TABLE.columns.map((res, index) => { | 
					
						
							|  |  |  |  |               if (map[tableName].ACCOUNT_TABLE.columns.length - 1 == index) { | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |                 str += data[res] ? `'${data[res]}'` : 'NULL' | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |               } else { | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |                 str += (data[res] ? `'${data[res]}'` : 'NULL') + ',' | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |               } | 
					
						
							|  |  |  |  |             }) | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |             if (i == resultArr.length - 1) { | 
					
						
							|  |  |  |  |               str += ')' | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |               str += '),' | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |             INSERT_SQL += str | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |           }) | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |           console.log('sqlsINSERT_SQLINSERT_SQL', INSERT_SQL) | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |           accountTable.sqlOperate(INSERT_SQL, tableName, (val) => { | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |             console.log('teststet3',val,tableName) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |             console.log('sqlsqlinsert,', val, 'tableName', tableName) | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |             resolve(val) | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |           }) | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |           if (delFlag) { | 
					
						
							|  |  |  |  |             await delSyncTable(tableName, context) | 
					
						
							| 
									
										
										
										
											2024-08-02 15:27:44 +08:00
										 |  |  |  |             const result = await sqlInsertCommonFn(tableName, resultArr, context) | 
					
						
							|  |  |  |  |             resolve(result) | 
					
						
							|  |  |  |  |             return | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |           } | 
					
						
							|  |  |  |  |           const result = await sqlInsertCommonFn(tableName, resultArr, context) | 
					
						
							| 
									
										
										
										
											2024-03-12 15:32:48 +08:00
										 |  |  |  |           resolve(result) | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |       }, true); | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     }, context); | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |   }) | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | //参数平台
 | 
					
						
							|  |  |  |  | export async function getDataBaseTable(params, reqParam) { | 
					
						
							|  |  |  |  |   return new Promise(async (resolve, reject) => { | 
					
						
							|  |  |  |  |     const date = new Date() | 
					
						
							|  |  |  |  |     if (!reqParam?.paraKdid) { | 
					
						
							|  |  |  |  |       prompt.showToast({ | 
					
						
							|  |  |  |  |         message: 'paraKdid获取失败', | 
					
						
							|  |  |  |  |         duration: 3000 | 
					
						
							|  |  |  |  |       }); | 
					
						
							|  |  |  |  |       return | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     const str = { "head": { "time": dateFormat(date) }, | 
					
						
							|  |  |  |  |       "body": | 
					
						
							|  |  |  |  |       { "tableName": params.tableName, // 表名
 | 
					
						
							|  |  |  |  |         "paraKdid": reqParam.paraKdid, //参数平台kdid
 | 
					
						
							|  |  |  |  |         "examinationRoomId": reqParam.examinationRoomId, //考试平台kdid
 | 
					
						
							|  |  |  |  |         "typeRsp": "0" // 赋默认值0,无需改变
 | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     let res: any = await initCenterCache(str, reqParam.centerHost) | 
					
						
							|  |  |  |  |     if (res.body[params.tableName].length == 0) { | 
					
						
							|  |  |  |  |       resolve(); | 
					
						
							|  |  |  |  |       return | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     if (params.tableName == 'MA_SYSSET') { | 
					
						
							|  |  |  |  |       res.body[params.tableName] = res.body[params.tableName].filter(res => { | 
					
						
							|  |  |  |  |         return res['v_no'] >= 300 && res['v_no'] <= 700 | 
					
						
							|  |  |  |  |       }) | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     sqlInsertCommonFn(param.tableName, res.body[params.tableName]).then((val) => { | 
					
						
							|  |  |  |  |       reslove(val) | 
					
						
							|  |  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   }) | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-26 15:01:27 +08:00
										 |  |  |  | //依据数组和表名更新sql表
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function upDateTableByArray(tableName, arr) { | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |   return new Promise(async (reslove, reject) => { | 
					
						
							|  |  |  |  |     const data = await sqlInsertCommonFn(tableName, arr) | 
					
						
							| 
									
										
										
										
											2024-08-02 15:27:44 +08:00
										 |  |  |  |     reslove(data) | 
					
						
							|  |  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2024-02-26 15:01:27 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-26 15:01:27 +08:00
										 |  |  |  | //更新双中心表
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function upDateTable(params, reqParam) { | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |   return new Promise((resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     const date = new Date() | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     let paraKdid = reqParam?.paraKdid || '' | 
					
						
							|  |  |  |  |     let examinationRoomId = reqParam?.examinationRoomId || '' | 
					
						
							|  |  |  |  |     if (!paraKdid || !examinationRoomId) { | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |       resolve(false) | 
					
						
							|  |  |  |  |       return | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     const str = { "head": { "time": dateFormat(date) }, | 
					
						
							|  |  |  |  |       "body": | 
					
						
							|  |  |  |  |       { "tableName": params.tableName, // 表名
 | 
					
						
							|  |  |  |  |         "paraKdid": paraKdid, //参数平台kdid
 | 
					
						
							|  |  |  |  |         "examinationRoomId": examinationRoomId, //考试平台kdid
 | 
					
						
							|  |  |  |  |         "typeRsp": "0" // 赋默认值0,无需改变
 | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     const url = globalThis.timeInfo.url | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     initCenterCache(str, url).then(async (res) => { | 
					
						
							|  |  |  |  |       if (!res || res == undefined || res == '') { | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |         resolve(false) | 
					
						
							|  |  |  |  |         return | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |       try { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |         const result = await sqlInsertCommonFn(params.tableName, res.body[params.tableName], reqParam.context) | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |         resolve(result) | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       } catch (error) { | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |         console.log(error) | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   }); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-21 13:34:14 +08:00
										 |  |  |  | //考试平台
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function getMySystemSetTable(params, reqParam) { | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |   return new Promise((resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |     const date = new Date() | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     if (!reqParam.paraKdid) { | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |       prompt.showToast({ | 
					
						
							|  |  |  |  |         message: 'paraKdid获取失败', | 
					
						
							|  |  |  |  |         duration: 3000 | 
					
						
							|  |  |  |  |       }); | 
					
						
							|  |  |  |  |       return | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |     const str = { "head": { "time": dateFormat(date) }, | 
					
						
							|  |  |  |  |       "body": | 
					
						
							|  |  |  |  |       { "tableName": params.tableName, // 表名
 | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         "paraKdid": reqParam?.kdid, //考试平台kdid
 | 
					
						
							|  |  |  |  |         "examinationRoomId": reqParam?.kdid, //考试平台kdid
 | 
					
						
							| 
									
										
										
										
											2024-02-21 17:00:55 +08:00
										 |  |  |  |         "typeRsp": "0" // 赋默认值0,无需改变
 | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     initCenterCacheByKSPT(str, reqParam.url).then((res) => { | 
					
						
							|  |  |  |  |       if (res.body[params.tableName].length == 0) { | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         resolve(); | 
					
						
							|  |  |  |  |         return | 
					
						
							|  |  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       if (params.tableName == 'MA_SYSSET') { | 
					
						
							|  |  |  |  |         res.body[params.tableName] = res.body[params.tableName].filter(res => { | 
					
						
							|  |  |  |  |           return res['v_no'] < 300 || res['v_no'] > 700 | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         }) | 
					
						
							|  |  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       sqlInsertCommonFn(params.tableName, res.body[params.tableName], reqParam.context, false).then((result) => { | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         resolve(result) | 
					
						
							|  |  |  |  |       }) | 
					
						
							|  |  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   }) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-26 15:01:27 +08:00
										 |  |  |  | //依据表名同步获取数据
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function getSyncData(tableName, context?) { | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   return new Promise((resolve, reject) => { | 
					
						
							|  |  |  |  |     const accountTable = new AccountTable(() => { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     }, map[tableName], context); | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     accountTable.getRdbStore(() => { | 
					
						
							|  |  |  |  |       accountTable.query('0', async (result) => { | 
					
						
							|  |  |  |  |         resolve(result) | 
					
						
							|  |  |  |  |       }, true); | 
					
						
							|  |  |  |  |     }); | 
					
						
							|  |  |  |  |   }) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-02-26 15:01:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function delSyncTable(tableName, context?) { | 
					
						
							|  |  |  |  |   return new Promise((resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     const accountTable = new AccountTable(() => { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     }, map[tableName], context); | 
					
						
							|  |  |  |  |     accountTable.deleteTableData((ret) => { | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |       console.log('删除成功') | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |       resolve(true) | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     }, tableName, context) | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   }) | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | //获取车模、场地模型
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function getEsCarModel(context) { | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   const date = new Date() | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   if (!globalThis.timeInfo?.paraKdid) { | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     prompt.showToast({ | 
					
						
							|  |  |  |  |       message: 'paraKdid获取失败', | 
					
						
							|  |  |  |  |       duration: 3000 | 
					
						
							|  |  |  |  |     }); | 
					
						
							|  |  |  |  |     return | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  |   const carStr = { "head": { "time": dateFormat(date) }, | 
					
						
							|  |  |  |  |     "body": | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       "rtkType": "1", //1:车模 2:场地模型
 | 
					
						
							|  |  |  |  |       "rspType": "0", //返回类型
 | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |       "paraKdid": globalThis.timeInfo.paraKdid, //参数平台kdid
 | 
					
						
							|  |  |  |  |       "examinationRoomId": globalThis.timeInfo.kdid, //考试平台kdid
 | 
					
						
							|  |  |  |  |       // "carMac":"MAC-HCPAD-210",
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       "carMac": globalThis.deviceNo | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   const venueStr = { "head": { "time": dateFormat(date) }, | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     "body": | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       "rtkType": "2", //1:车模 2:场地模型
 | 
					
						
							|  |  |  |  |       "rspType": "0", //返回类型
 | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |       "paraKdid": globalThis.timeInfo.paraKdid, //参数平台kdid
 | 
					
						
							|  |  |  |  |       "examinationRoomId": globalThis.timeInfo.kdid, //考试平台kdid
 | 
					
						
							|  |  |  |  |       // "carMac":"MAC-HCPAD-210",
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       "carMac": globalThis.deviceNo | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   let carRes: any = await initEsModel(carStr); | 
					
						
							|  |  |  |  |   let venueRes: any = await initEsModel(venueStr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   const carModel = carRes.body.ES_MODEL[0][1]; | 
					
						
							|  |  |  |  |   const venueModel = venueRes.body.ES_MODEL[0][2]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   let tmpBase64Array = carModel.split("\r\n") | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   let newBase64Str: string = ''; | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   for (let i = 0; i < tmpBase64Array.length; ++i) { | 
					
						
							|  |  |  |  |     newBase64Str += tmpBase64Array[i]; | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  |   const base64 = new util.Base64(); | 
					
						
							|  |  |  |  |   let result = base64.decodeSync(newBase64Str); | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |   const fileModel = new FileModel(context); | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   await fileModel.initFolder() | 
					
						
							|  |  |  |  |   await fileModel.storingFiles(result.buffer) | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | export async function upDataZhongxinginitialization(param) { | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |   return new Promise(async(resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     if (!param.carId) { | 
					
						
							| 
									
										
										
										
											2024-01-31 14:35:16 +08:00
										 |  |  |  |       resolve(false) | 
					
						
							|  |  |  |  |       return | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |     let flag=true | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |     if (param.singlePlay) { | 
					
						
							| 
									
										
										
										
											2024-08-21 18:05:24 +08:00
										 |  |  |  |       console.log('teststet0',JSON.stringify(param)) | 
					
						
							| 
									
										
										
										
											2024-08-12 14:46:16 +08:00
										 |  |  |  |       const fileUtil = new FileUtil(param.context) | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |       const tableList = ['MA_SYSSET', 'MA_SYSTEMPARM', 'MA_MARKRULE', 'MA_MARKRULESET','ES_CARINFO','MA_MAP_ROAD','MA_MAP_ROAD_LANE','MAP_SUBITEM','MA_T_CARPARMSET','MA_MAP_ITEMCLASS','MA_MAP_POINT','MA_MAP_POINT_ITEM']; | 
					
						
							|  |  |  |  |      for(let i=0;i<=tableList.length-1;i++){ | 
					
						
							|  |  |  |  |        const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableList[i]}.txt`); | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |        const result=await sqlInsertCommonFn(tableList[i], JSON.parse(data) || [], param.context) | 
					
						
							| 
									
										
										
										
											2024-08-21 18:05:24 +08:00
										 |  |  |  |        result?(flag=true):(flag=false) | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |      } | 
					
						
							| 
									
										
										
										
											2024-08-21 18:05:24 +08:00
										 |  |  |  |       if(!flag){ | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |         prompt.showToast({ | 
					
						
							|  |  |  |  |           message: '本地文件初始化数据库失败', | 
					
						
							|  |  |  |  |           duration: 3000 | 
					
						
							|  |  |  |  |         }); | 
					
						
							|  |  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-08-21 18:05:24 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-19 09:32:41 +08:00
										 |  |  |  |       resolve(flag) | 
					
						
							| 
									
										
										
										
											2024-08-12 14:46:16 +08:00
										 |  |  |  |       return | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |     try{ | 
					
						
							|  |  |  |  |       const str = { | 
					
						
							|  |  |  |  |         "carId": param.carId, // 表名
 | 
					
						
							|  |  |  |  |         "examinationRoomId": param.examinationRoomId, //考试平台kdid
 | 
					
						
							|  |  |  |  |         videoVersion: '1.0', | 
					
						
							|  |  |  |  |         judgeVersion: param.judgeVersion, | 
					
						
							|  |  |  |  |         shellVersion: param.shellVersion, | 
					
						
							|  |  |  |  |         host: param.host | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |       console.log('daihai2', JSON.stringify(str)) | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |       initialization(str).then(async (res) => { | 
					
						
							|  |  |  |  |         console.log('daihai3', JSON.stringify(res)) | 
					
						
							|  |  |  |  |         if (!res||res.initializationRsp.head.resultCode==1) { | 
					
						
							|  |  |  |  |           console.log('daihai34', JSON.stringify(res)) | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  |           resolve(false) | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |           return | 
					
						
							| 
									
										
										
										
											2024-07-09 11:11:31 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |         let flag | 
					
						
							|  |  |  |  |         console.log('resposestart') | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         for (let key in res.initializationRsp.body) { | 
					
						
							|  |  |  |  |           if (!centerToMap[key]) { | 
					
						
							|  |  |  |  |             continue | 
					
						
							|  |  |  |  |           } | 
					
						
							|  |  |  |  |           const data = await setSyncCenterSqlData(key, res, param) | 
					
						
							|  |  |  |  |           if (!data) { | 
					
						
							|  |  |  |  |             resolve(false) | 
					
						
							|  |  |  |  |           } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         resolve(true) | 
					
						
							| 
									
										
										
										
											2024-07-09 11:11:31 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |         console.log('resposestart') | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |       }).catch((Error) => { | 
					
						
							|  |  |  |  |         resolve(false) | 
					
						
							|  |  |  |  |       }) | 
					
						
							|  |  |  |  |     }catch (error){ | 
					
						
							| 
									
										
										
										
											2024-05-16 09:53:10 +08:00
										 |  |  |  |       resolve(false) | 
					
						
							| 
									
										
										
										
											2024-08-21 11:57:03 +08:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-01-31 14:35:16 +08:00
										 |  |  |  |   }) | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | function setSyncCenterSqlData(key, res, param) { | 
					
						
							| 
									
										
										
										
											2024-08-14 17:26:27 +08:00
										 |  |  |  |   return new Promise(async (resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     const mapName = { | 
					
						
							|  |  |  |  |       'ItemInfo': 'MA_ITEMINFO', | 
					
						
							|  |  |  |  |       'MarkRule': 'MA_MARKRULE', | 
					
						
							|  |  |  |  |       'SystemParm': 'MA_SYSTEMPARM', | 
					
						
							| 
									
										
										
										
											2024-07-03 16:21:56 +08:00
										 |  |  |  |       'Map_Collect': 'MA_MAP_COLLECT', | 
					
						
							|  |  |  |  |       'Map_Collect_Shape': 'MA_MAP_COLLECT_SHAPE', | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       'Map_ItemClass': 'MA_MAP_ITEMCLASS', | 
					
						
							|  |  |  |  |       'Map_Point': 'MA_MAP_POINT', | 
					
						
							|  |  |  |  |       'Map_Point_Item': 'MA_MAP_POINT_ITEM', | 
					
						
							|  |  |  |  |       'Map_Road': 'MA_MAP_ROAD', | 
					
						
							|  |  |  |  |       'Map_Road_Lane': 'MA_MAP_ROAD_LANE', | 
					
						
							|  |  |  |  |       'Map_SubItem': 'MAP_SUBITEM', | 
					
						
							|  |  |  |  |       'Sysset': 'MA_SYSSET', | 
					
						
							|  |  |  |  |       'CarInfo': 'ES_CARINFO', | 
					
						
							| 
									
										
										
										
											2024-01-31 14:35:16 +08:00
										 |  |  |  |       // 'ES_EXAMPOINTDETAIL':ES_EXAMPOINTDETAIL,
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       'MarkRuleSet': 'MA_MARKRULESET', | 
					
						
							|  |  |  |  |       'Cdsbinfo': 'MA_CDSBINFO', | 
					
						
							|  |  |  |  |       'T_CarParmSet': 'MA_T_CARPARMSET', | 
					
						
							| 
									
										
										
										
											2024-01-31 14:35:16 +08:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |     // const accountTable = new AccountTable(() => {
 | 
					
						
							|  |  |  |  |     // }, centerToMap[key],param.context);
 | 
					
						
							|  |  |  |  |     let arrList | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     if (res.initializationRsp.body[key].record instanceof Array) { | 
					
						
							|  |  |  |  |       arrList = res.initializationRsp.body[key].record | 
					
						
							|  |  |  |  |     } else { | 
					
						
							|  |  |  |  |       arrList = [res.initializationRsp.body[key].record] | 
					
						
							| 
									
										
										
										
											2024-01-31 14:35:16 +08:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-08-12 14:46:16 +08:00
										 |  |  |  |     const fileUtil = new FileUtil(param.context) | 
					
						
							|  |  |  |  |     const folderPath = await fileUtil.initFolder(`/config/tableList`); | 
					
						
							|  |  |  |  |     fileUtil.addFile(`${folderPath}/${mapName[key]}.txt`, JSON.stringify(arrList)) | 
					
						
							| 
									
										
										
										
											2024-08-15 13:42:36 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     console.log('mapName[key]', mapName[key], key) | 
					
						
							|  |  |  |  |     sqlInsertCommonFn(mapName[key], arrList, param.context).then((result) => { | 
					
						
							|  |  |  |  |       console.log(key, '表建立成功') | 
					
						
							|  |  |  |  |       if (result) { | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         resolve(true) | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       } else { | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |         resolve(false) | 
					
						
							|  |  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |     }).catch((msg) => { | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |       reject(false) | 
					
						
							| 
									
										
										
										
											2024-07-29 14:29:32 +08:00
										 |  |  |  |       console.log(key, '表建立失败') | 
					
						
							| 
									
										
										
										
											2024-06-27 20:53:36 +08:00
										 |  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2024-02-22 10:40:35 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-05 11:11:15 +08:00
										 |  |  |  | } |