fix: 优化落盘操作,优化数据操作

This commit is contained in:
wangzhongjie 2025-03-11 10:44:01 +08:00
parent ac408a3281
commit 21a5067117
4 changed files with 93 additions and 63 deletions

View File

@ -96,6 +96,10 @@ export async function initTable() {
export function sqlInsertCommonFn(tableName, resultArr, delFlag = true) { export function sqlInsertCommonFn(tableName, resultArr, delFlag = true) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
DB.clearTable(tableName).then((res) => { DB.clearTable(tableName).then((res) => {
if (!resultArr || resultArr.length == 0) {
resolve(true)
return
}
let INSERT_SQL = "INSERT INTO " + tableName let INSERT_SQL = "INSERT INTO " + tableName
+ " (" + map[tableName].ACCOUNT_TABLE.columns.toString() + ") VALUES " + " (" + map[tableName].ACCOUNT_TABLE.columns.toString() + ") VALUES "
@ -190,9 +194,11 @@ export async function getDataBaseTable(params, reqParam) {
}); });
return return
} }
const str = { "head": { "time": dateFormat(date) }, const str = {
"head": { "time": dateFormat(date) },
"body": "body":
{ "tableName": params.tableName, // 表名 {
"tableName": params.tableName, // 表名
"paraKdid": reqParam.paraKdid, //参数平台kdid "paraKdid": reqParam.paraKdid, //参数平台kdid
"examinationRoomId": reqParam.examinationRoomId, //考试平台kdid "examinationRoomId": reqParam.examinationRoomId, //考试平台kdid
"typeRsp": "0" // 赋默认值0无需改变 "typeRsp": "0" // 赋默认值0无需改变
@ -233,9 +239,11 @@ export async function upDateTable(params, reqParam) {
return return
} }
const str = { "head": { "time": dateFormat(date) }, const str = {
"head": { "time": dateFormat(date) },
"body": "body":
{ "tableName": params.tableName, // 表名 {
"tableName": params.tableName, // 表名
"paraKdid": reqParam.paraKdid, //参数平台kdid "paraKdid": reqParam.paraKdid, //参数平台kdid
"examinationRoomId": reqParam.kdid, //考试平台kdid "examinationRoomId": reqParam.kdid, //考试平台kdid
"typeRsp": "0" // 赋默认值0无需改变 "typeRsp": "0" // 赋默认值0无需改变
@ -269,9 +277,11 @@ export async function getMySystemSetTable(params, reqParam) {
}); });
return return
} }
const str = { "head": { "time": dateFormat(date) }, const str = {
"head": { "time": dateFormat(date) },
"body": "body":
{ "tableName": params.tableName, // 表名 {
"tableName": params.tableName, // 表名
"paraKdid": reqParam?.paraKdid, //参数平台kdid "paraKdid": reqParam?.paraKdid, //参数平台kdid
"examinationRoomId": reqParam?.kdid, //考试平台kdid "examinationRoomId": reqParam?.kdid, //考试平台kdid
"typeRsp": "0" // 赋默认值0无需改变 "typeRsp": "0" // 赋默认值0无需改变
@ -347,7 +357,8 @@ export async function getEsCarModel(context) {
}); });
return return
} }
const carStr = { "head": { "time": dateFormat(date) }, const carStr = {
"head": { "time": dateFormat(date) },
"body": "body":
{ {
"rtkType": "1", //1:车模 2:场地模型 "rtkType": "1", //1:车模 2:场地模型
@ -358,7 +369,8 @@ export async function getEsCarModel(context) {
"carMac": globalThis.deviceNo "carMac": globalThis.deviceNo
} }
} }
const venueStr = { "head": { "time": dateFormat(date) }, const venueStr = {
"head": { "time": dateFormat(date) },
"body": "body":
{ {
"rtkType": "2", //1:车模 2:场地模型 "rtkType": "2", //1:车模 2:场地模型
@ -396,9 +408,12 @@ export async function upDataZhongxinginitialization(param) {
if (param.singlePlay) { if (param.singlePlay) {
console.log('teststet0', JSON.stringify(param)) console.log('teststet0', JSON.stringify(param))
const fileUtil = new FileUtil(param.context) const fileUtil = new FileUtil(param.context)
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']; 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++) { for (let i = 0; i <= tableList.length - 1; i++) {
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableList[i]}.txt`); const data =
await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableList[i]}.txt`);
const result = await sqlInsertCommonFn(tableList[i], JSON.parse(data) || [], param.context) const result = await sqlInsertCommonFn(tableList[i], JSON.parse(data) || [], param.context)
result ? (flag = true) : (flag = false) result ? (flag = true) : (flag = false)

View File

@ -57,8 +57,7 @@ export async function startRecordVideo(param, td, context, dir, path?, index?) {
var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, date, dir); var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, date, dir);
const handleId = recordResult.dataInt; const handleId = recordResult.dataInt;
reslove(handleId) reslove(handleId)
} } else {
else {
console.log(`Rtsprecord startRecordVideo rtsp_server isnull`); console.log(`Rtsprecord startRecordVideo rtsp_server isnull`);
reslove(0) reslove(0)
} }
@ -74,10 +73,10 @@ export async function endRecordVideo(record_handleObj) {
console.log(`Rtsprecord endRecordVideo begin`); console.log(`Rtsprecord endRecordVideo begin`);
// @ts-ignore // @ts-ignore
var recordResult = rtsp_server.endRecordVideo(record_handleObj[key]); var recordResult = rtsp_server.endRecordVideo(record_handleObj[key]);
console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` + record_handleObj[key].fileName); console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` +
record_handleObj[key].fileName);
} } else {
else {
console.log(`Rtsprecord endRecordVideo handleId isnull`); console.log(`Rtsprecord endRecordVideo handleId isnull`);
} }
} }
@ -123,7 +122,8 @@ async function getfilehandleCode(td, param, dir, path, index) {
} }
export async function getUserAlbumItemByDisplayName(displayName: string, day?, type?): Promise<photoAccessHelper.Album> { export async function getUserAlbumItemByDisplayName(displayName: string, day?,
type?): Promise<photoAccessHelper.Album> {
let fetchResult = null let fetchResult = null
let album: photoAccessHelper.Album = null let album: photoAccessHelper.Album = null
try { try {
@ -136,7 +136,9 @@ export async function getUserAlbumItemByDisplayName(displayName: string, day?, t
}; };
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(globalThis.context); const userFileMgr = photoAccessHelper.getPhotoAccessHelper(globalThis.context);
fetchResult = await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); fetchResult =
await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC,
fetchOptions);
console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult));
if (fetchResult.getCount() > 0) { if (fetchResult.getCount() > 0) {
const albums = await fetchResult.getLastObject(); const albums = await fetchResult.getLastObject();
@ -194,7 +196,9 @@ export async function delPic(day, type) {
fetchColumns: [], fetchColumns: [],
predicates: predicates predicates: predicates
}; };
let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions); let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC,
albumFetchOptions);
let albums = await albumList.getAllObjects(); let albums = await albumList.getAllObjects();
for (let i = 0; i <= albums.length; i++) { for (let i = 0; i <= albums.length; i++) {
let albumName = albums[i].albumName let albumName = albums[i].albumName
@ -223,8 +227,7 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) {
console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize); console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize);
callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode }) callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode })
}); });
} } else {
else {
return new Promise<takePhotoParam>(async (resolve, reject) => { return new Promise<takePhotoParam>(async (resolve, reject) => {
const time = await getCurrentTime() const time = await getCurrentTime()
const date = time.split(' ')[0] const date = time.split(' ')[0]
@ -264,7 +267,8 @@ export async function deleteAllFileByPiC(dirName, type = 1) {
fileHelper.deleteFileOfAlbum(dirName, type); fileHelper.deleteFileOfAlbum(dirName, type);
} }
export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> { export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType,
subType: photoAccessHelper.AlbumSubtype): Promise<void> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
try { try {
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context); const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);

View File

@ -637,7 +637,8 @@ struct UserInfo {
this.ksksLimit = false this.ksksLimit = false
// this.isBoardPrePareSetPopupOpen=true // this.isBoardPrePareSetPopupOpen=true
this.isFirstBoardPrePareSetPopupBtnShow = false this.isFirstBoardPrePareSetPopupBtnShow = false
console.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow, this.isBoardPrePareSetPopupOpen) console.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow,
this.isBoardPrePareSetPopupOpen)
this.startExam = false this.startExam = false
// await upDateTableByArray('USER', []) // await upDateTableByArray('USER', [])
// await upDateTableByArray('USERLIST', []) // await upDateTableByArray('USERLIST', [])
@ -646,10 +647,14 @@ struct UserInfo {
this.type = '2' this.type = '2'
this.errorDialog.open() this.errorDialog.open()
this.updateTimeLimit = true this.updateTimeLimit = true
const param = `<getExaminationStudentInfoReq><head><checkCode>${Md5.Instance.get_md5(globalThis.carInfo.carId + globalThis.carInfo.examinationRoomId + globalThis.username)}</checkCode></head><body><carId>${globalThis.carInfo.carId}</carId><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><sfzmhm></sfzmhm></body></getExaminationStudentInfoReq>` const param = `<getExaminationStudentInfoReq><head><checkCode>${Md5.Instance.get_md5(globalThis.carInfo.carId +
globalThis.carInfo.examinationRoomId +
globalThis.username)}</checkCode></head><body><carId>${globalThis.carInfo.carId}</carId><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><sfzmhm></sfzmhm></body></getExaminationStudentInfoReq>`
try { try {
getExaminationStudentInfo(param).then(async (res) => { getExaminationStudentInfo(param).then(async (res) => {
console.log("temp log ", JSON.stringify(res)) console.log("temp log ", JSON.stringify(res))
await DB.clearTable('USER')
await DB.clearTable('USERLIST')
this.errorDialog.close() this.errorDialog.close()
setTimeout(() => { setTimeout(() => {
this.updateTimeLimit = false this.updateTimeLimit = false
@ -795,7 +800,8 @@ struct UserInfo {
return return
} }
console.log('JsonJson', JSON.stringify(this.currentUser)) console.log('JsonJson', JSON.stringify(this.currentUser))
const param = `<?xml version="1.0" encoding="UTF-8" ?><examinationStuAbsentReq><body><carId>${globalThis.carInfo.carId}</carId><cardNo>${this.currentUser.sfzmhm}</cardNo><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><lsh>${this.lsh}</lsh></body></examinationStuAbsentReq>` const param =
`<?xml version="1.0" encoding="UTF-8" ?><examinationStuAbsentReq><body><carId>${globalThis.carInfo.carId}</carId><cardNo>${this.currentUser.sfzmhm}</cardNo><examinationRoomId>${globalThis.carInfo.examinationRoomId}</examinationRoomId><examinerName>${globalThis.username}</examinerName><lsh>${this.lsh}</lsh></body></examinationStuAbsentReq>`
console.log('carNo1111', param) console.log('carNo1111', param)
examinationStuAbsent(param).then(res => { examinationStuAbsent(param).then(res => {
@ -1119,11 +1125,13 @@ struct UserInfo {
} }
.width(165 * this.ratio) .width(165 * this.ratio)
.height(85 * this.ratio) .height(85 * this.ratio)
.backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg')) .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') :
$r('app.media.userboxbg'))
.backgroundImageSize({ width: '100%', height: '100%' }) .backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => { .onClick(() => {
console.log('this.startExam', this.startExam, this.systemParam.Param364, this.isExamStart) console.log('this.startExam', this.startExam, this.systemParam.Param364, this.isExamStart)
if ((this.isExamStart && !globalThis.singlePlay && this.systemParam.Param341) || (this.startExam && this.systemParam.Param364 == '2')) { if ((this.isExamStart && !globalThis.singlePlay && this.systemParam.Param341) ||
(this.startExam && this.systemParam.Param364 == '2')) {
return return
} }
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
@ -1218,14 +1226,17 @@ struct UserInfo {
.onClick(() => { .onClick(() => {
// this.avPlayer.playAudio(['button_media.wav']) // this.avPlayer.playAudio(['button_media.wav'])
// 已开始考试不能缺考 已考过一次学员不能缺考 车上不能缺考 // 已开始考试不能缺考 已考过一次学员不能缺考 车上不能缺考
if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') || this.systemParam.Param770Str == '1') { if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') ||
this.systemParam.Param770Str == '1') {
return return
} }
this.ksksLimit = true this.ksksLimit = true
this.qkFlag = true this.qkFlag = true
}) })
if (this.isBoardPrePareSetPopupOpen && (this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') && !this.isFirstBoardPrePareSetPopupBtnShow) { if (this.isBoardPrePareSetPopupOpen &&
(this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') &&
!this.isFirstBoardPrePareSetPopupBtnShow) {
//上车准备 //上车准备
// Image($r('app.media.sczb_btn')).commStyle() // Image($r('app.media.sczb_btn')).commStyle()
imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.sczb_btn') }) imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.sczb_btn') })

View File

@ -13,16 +13,37 @@ interface Params {
} }
export default class FilePhoto { export default class FilePhoto {
public mediaTest
private params: Params private params: Params
private context: any private context: any
public getPhoto = async () => {
const { params } = this;
if (!judgeConfig.isPhotoOpen) {
return ''
} else {
try {
console.info('surenjun', '拍照开始')
const res = await takePhoto(params, this.context, 'pz/', 0);
console.info('surenjun', '拍照结束' + JSON.stringify(res))
return res.base64
} catch (e) {
console.error('surenjun =>拍照异常' + JSON.stringify(e))
promptAction.showToast({
message: '拍照异常,请联系工程人员!',
duration: 2000
});
return ''
}
}
}
private fileUtil: FileUtil private fileUtil: FileUtil
public mediaTest
constructor(context) { constructor(context) {
(async () => { (async () => {
//TODO 309参数 获取拍照摄像头拍照通道 //TODO 309参数 获取拍照摄像头拍照通道
const fileUtil = new FileUtil(context) const fileUtil = new FileUtil(context)
const strConfig = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/config/config3.txt'); const strConfig =
await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/config/config3.txt');
const config = JSON.parse(strConfig) const config = JSON.parse(strConfig)
const { userName, ip, pwd, port, rlls, pztd } = config const { userName, ip, pwd, port, rlls, pztd } = config
this.params = { this.params = {
@ -37,25 +58,4 @@ export default class FilePhoto {
this.fileUtil = fileUtil this.fileUtil = fileUtil
})() })()
} }
public getPhoto = async () => {
const {params} = this;
if (!judgeConfig.isPhotoOpen) {
return ''
} else {
try {
console.info('surenjun', '拍照开始')
const res = await takePhoto(params, this.context, 'pz/', 2);
console.info('surenjun', '拍照结束' + JSON.stringify(res))
return res.base64
} catch (e) {
console.error('surenjun =>拍照异常' + JSON.stringify(e))
promptAction.showToast({
message: '拍照异常,请联系工程人员!',
duration: 2000
});
return ''
}
}
}
} }