fix: 优化初始化表相关的类型结构

This commit is contained in:
wangzhongjie 2025-04-15 14:24:27 +08:00
parent 636ba1fb15
commit 2a6eb111a3
10 changed files with 188 additions and 144 deletions

View File

@ -6,13 +6,13 @@ export interface User {
lsh: string lsh: string
ksy1: string ksy1: string
ksy2: string ksy2: string
id: string id?: string
kszp: string kszp: string
ksmjzp: string ksmjzp: string
bz1: string bz1: string
jxmc: string jxmc: string
kchp: string kchp: string
kscx: string kscx?: string
ksdd: string ksdd: string
kssycs: string kssycs: string
ksxl: string ksxl: string
@ -189,9 +189,9 @@ export interface JudgeConfigType{
fourInOneScreen: FourInOneScreenType fourInOneScreen: FourInOneScreenType
systemParamConfig?: SystemParamConfigType systemParamConfig?: SystemParamConfigType
} }
interface FourInOneScreenType { interface FourInOneScreenType {
gpsDigit: number gpsDigit: number
} }
interface SystemParamConfigType{
} interface SystemParamConfigType {}

View File

@ -127,12 +127,12 @@ export interface ES_CARINFOType {
// 'id', 'no1', 'no2', 'no3', 'txt1', 'txt2', 'txt3' // 'id', 'no1', 'no2', 'no3', 'txt1', 'txt2', 'txt3'
export interface MA_SYSTEMPARMType { export interface MA_SYSTEMPARMType {
id?: string id?: string
no1: string no1?: string
no2: string no2?: string
no3: string no3?: string
txt1: string txt1?: string
txt2: string txt2?: string
txt3: string txt3?: string
NO1?: number, NO1?: number,
NO2?: number, NO2?: number,
NO3?: number, NO3?: number,
@ -143,33 +143,33 @@ export interface MA_SYSTEMPARMType {
// 'id', 'sbbm', 'itemsno', 'sbbh', 'kdid', 'bk3' // 'id', 'sbbm', 'itemsno', 'sbbh', 'kdid', 'bk3'
export interface MA_CDSBINFOType { export interface MA_CDSBINFOType {
id: string id?: string
sbbm: string sbbm?: string
itemsno: string itemsno?: string
sbbh: string sbbh?: string
kdid: string kdid?: string
bk3: string bk3?: string
} }
// 'id', 'cininfo', 'setup9', 'nextinfo', 'setup7', 'setup8', 'setup5', 'carlist', 'setup6', 'setup3', // 'id', 'cininfo', 'setup9', 'nextinfo', 'setup7', 'setup8', 'setup5', 'carlist', 'setup6', 'setup3',
// 'setup4', 'setup1', 'setup2', 'itemsno', 'end_cardsno', 'freqinfo' // 'setup4', 'setup1', 'setup2', 'itemsno', 'end_cardsno', 'freqinfo'
export interface MA_ITEMINFOType { export interface MA_ITEMINFOType {
id: string id?: string
cininfo: string cininfo?: string
setup9: string setup9?: string
nextinfo: string nextinfo?: string
setup7: string setup7?: string
setup8: string setup8?: string
setup5: string setup5?: string
carlist: string carlist?: string
setup6: string setup6?: string
setup3: string setup3?: string
setup4: string setup4?: string
setup1: string setup1?: string
setup2: string setup2?: string
itemsno: string itemsno?: string
end_cardsno: string end_cardsno?: string
freqinfo: string freqinfo?: string
} }
// 'id', 'point_no', 'point_no_f', 'gps_e', 'gps_e_location', 'gps_n', 'gps_n_location', 'f_gps_e', // 'id', 'point_no', 'point_no_f', 'gps_e', 'gps_e_location', 'gps_n', 'gps_n_location', 'f_gps_e',
@ -212,7 +212,4 @@ export interface MA_MARKRULEType {
markshow?: string markshow?: string
txt1?: string txt1?: string
kfxh?: string kfxh?: string
} }

View File

@ -1,4 +1,15 @@
import { CarInfoType, DrvexamType } from '.'; import {
CarInfoType,
DrvexamType,
ES_CARINFOType,
MA_CDSBINFOType,
MA_ITEMINFOType,
MA_MAP_POINT_ITEMType,
MA_MAP_POINTType,
MA_MARKRULEType,
MA_SYSTEMPARMType,
User
} from '.';
// -----new----- // -----new-----
export interface ApiResponseType { export interface ApiResponseType {
@ -147,9 +158,49 @@ interface RegistrationDeviceNoRspDetails {
interface ImageCompareRsp { interface ImageCompareRsp {
head: Head; head: Head;
body: ESObject body: ImageCompareRspBodyType
} }
interface ImageCompareRspBodyType {
GunCameraInfo: GunCameraInfo,
Sysset: Sysset,
SystemParm: SystemParm,
MarkRule: MarkRuleType,
MarkRuleSet: MarkRuleSet,
Cdsbinfo: Cdsbinfo,
CarInfo: CarInfo,
ItemInfo: ItemInfoType
}
//-----开始 初始化表结构---
interface RecordContainer<T> {
record: Array<T> | T;
}
export type PublicInfoType = RecordContainer<RecordType>;
export type GunCameraInfo = RecordContainer<RecordType>;
export type Sysset = RecordContainer<RecordType>;
export type SystemParm = RecordContainer<RecordType>;
export type MarkRuleType = RecordContainer<RecordType>;
export type MarkRuleSet = RecordContainer<RecordType>;
export type Cdsbinfo = RecordContainer<RecordType>;
export type CarInfo = RecordContainer<RecordType>;
export type ItemInfoType = RecordContainer<RecordType>;
export interface RecordType extends User, MA_SYSTEMPARMType, ES_CARINFOType, MA_SYSTEMPARMType, MA_CDSBINFOType, MA_ITEMINFOType, MA_MAP_POINTType, MA_MAP_POINT_ITEMType, MA_MARKRULEType {}
//-----结束 初始化表结构---
export interface GetExaminationStudentInfoResponse { export interface GetExaminationStudentInfoResponse {
getExaminationStudentInfoRsp: ImageCompareRsp getExaminationStudentInfoRsp: ImageCompareRsp

View File

@ -2,16 +2,14 @@ import common from '@ohos.app.ability.common';
import router from '@ohos.router'; import router from '@ohos.router';
import { JudgeConfig } from '../config'; import { JudgeConfig } from '../config';
import promptAction from '@ohos.promptAction';
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
import { BaseInfoType, centerCallBackMsgType } from '../model/Common'; import { BaseInfoType, centerCallBackMsgType } from '../model/Common';
import { CarInfoType, InitializeTheCentralTableType, MASYSSETTableType, TimeSynchronizationRspBody } from '../model'; import { CarInfoType, InitializeTheCentralTableType, MASYSSETTableType, TimeSynchronizationRspBody } from '../model';
import { GetCarInfo, GetDeviceInfo, SetCurrentTime, UseAuth } from './Index/utils'; import { CreateAlbum, GetCarInfo, GetDeviceInfo, SetCurrentTime, UseAuth } from './Index/utils';
import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation'; import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
import { delPic } from '../utils/Video'; import { delPic } from '../utils/Video';
import { FileHelper } from '../utils/FileHelp'; import { FileHelper } from '../utils/FileHelp';
import { GetCurrentTime } from '../utils/Common';
import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness'; import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness';
import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness'; import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness';
import { DrivingDataStorage } from '../utils/business/DrivingDataStorage'; import { DrivingDataStorage } from '../utils/business/DrivingDataStorage';
@ -21,6 +19,7 @@ import HeaderComponent from './compontents/Header';
import CardComponent from './Index/Card'; import CardComponent from './Index/Card';
import BottomMessageComponent from './Index/BottomMessage'; import BottomMessageComponent from './Index/BottomMessage';
import LoadingComponent from './Index/Loading'; import LoadingComponent from './Index/Loading';
import Prompt from '@system.prompt';
@Entry @Entry
@ -96,7 +95,7 @@ struct Index {
onlineExam() { onlineExam() {
this.customDialogController.open() this.customDialogController.open()
if (!this.timeInfo) { if (!this.timeInfo) {
promptAction.showToast({ Prompt.showToast({
message: `时间同步接口连接失败`, message: `时间同步接口连接失败`,
duration: 3000 duration: 3000
}); });
@ -104,14 +103,14 @@ struct Index {
return return
} }
if (!this.carInfo) { if (!this.carInfo) {
promptAction.showToast({ Prompt.showToast({
message: `车辆信息接口获取失败`, message: `车辆信息接口获取失败`,
duration: 3000 duration: 3000
}); });
this.customDialogController.close() this.customDialogController.close()
return return
} }
this.testXMLToJSONInWorker() this.initializationTableRelated()
} }
// 单机训练逻辑处理 // 单机训练逻辑处理
@ -130,12 +129,12 @@ struct Index {
url: 'pages/UserInfo', url: 'pages/UserInfo',
}, router.RouterMode.Single) }, router.RouterMode.Single)
} else { } else {
this.testXMLToJSONInWorker() this.initializationTableRelated()
} }
}); });
} }
async testXMLToJSONInWorker() { async initializationTableRelated() {
const param: InitializeTheCentralTableType = { const param: InitializeTheCentralTableType = {
carId: this.carInfo?.carId, carId: this.carInfo?.carId,
examinationRoomId: this.carInfo?.examinationRoomId, examinationRoomId: this.carInfo?.examinationRoomId,
@ -171,18 +170,12 @@ struct Index {
} }
}) })
}); });
} else {
this.customDialogController.close()
} }
}) })
} }
async createAlbum() {
const time = GetCurrentTime()
const date = time.split(' ')[0]
this.fileHelper.createAlbum('jt')
this.fileHelper.createAlbum('pz');
this.fileHelper.createAlbum(date);
}
async initParams() { async initParams() {
console.log("test1111") console.log("test1111")
ObtainUdpBusinessInstance.init(); ObtainUdpBusinessInstance.init();
@ -205,7 +198,7 @@ struct Index {
// takePhotoFn(this.context) // takePhotoFn(this.context)
// TODO // TODO
// CenterUDPBusinessInstance.startHeartBeat() // CenterUDPBusinessInstance.startHeartBeat()
this.createAlbum() CreateAlbum(this.fileHelper)
} }
build() { build() {

View File

@ -19,6 +19,7 @@ import { BusinessError } from '@ohos.base';
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
import { VideoConfigData } from '../../mock'; import { VideoConfigData } from '../../mock';
import FileUtils from '../../utils/FileUtils'; import FileUtils from '../../utils/FileUtils';
import { FileHelper } from '../../utils/FileHelp';
//获取设备信息 //获取设备信息
export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> { export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> {
@ -40,6 +41,7 @@ export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<s
}) })
} }
// 获取车辆信息
export async function GetCarInfo(): Promise<CarInfoType> { export async function GetCarInfo(): Promise<CarInfoType> {
let date = new Date(); let date = new Date();
let params: ObtainCarExamInfoParams = { let params: ObtainCarExamInfoParams = {
@ -156,3 +158,9 @@ export async function SetSerialNumber() {
} }
} }
export function CreateAlbum(fileHelper: FileHelper) {
const date = dayTs().format("YYYY-MM-DD")
fileHelper.createAlbum('jt')
fileHelper.createAlbum('pz');
fileHelper.createAlbum(date);
}

View File

@ -10,17 +10,9 @@ import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon';
import { uploadExamMileage } from '../api/judge'; import { uploadExamMileage } from '../api/judge';
import DwztErrorPopup from './compontents/judge/DwztErrorPopup'; import DwztErrorPopup from './compontents/judge/DwztErrorPopup';
import MsgPopup from './compontents/judge/MsgPopup'; import MsgPopup from './compontents/judge/MsgPopup';
import { import { CARINFO, CDSBInfo, LANE, MAPITEMPOINTITEM, MAPPOINT, Project, SYSTEMPARMARR } from './judgeSDK/api/judgeSDK.d';
CARINFO,
CDSBInfo,
LANE,
MAPITEMPOINTITEM,
MAPPOINT,
Project,
SYSTEMPARMARR
} from './judgeSDK/api/judgeSDK.d';
import {JudgeConfig} from"../config" import { JudgeConfig } from '../config';
import SignDisplayCom from './compontents/SignDisplayCom'; import SignDisplayCom from './compontents/SignDisplayCom';
import { import {
@ -33,12 +25,12 @@ import {
JudgeBeginObj, JudgeBeginObj,
JudgeCallBacData, JudgeCallBacData,
JudgeInitObj, JudgeInitObj,
JudgeUI,
MA_CDSBINFOType, MA_CDSBINFOType,
MA_ITEMINFOType, MA_ITEMINFOType,
MA_MAP_POINT_ITEMType, MA_MAP_POINT_ITEMType,
MA_MAP_POINTType, MA_MAP_POINTType,
MA_SYSTEMPARMType, MA_SYSTEMPARMType,
MarkRule,
MarkRules, MarkRules,
MASYSSETTableType, MASYSSETTableType,
ProjectInfo, ProjectInfo,
@ -47,8 +39,7 @@ import {
RouteParamsType, RouteParamsType,
SYSSET, SYSSET,
SyssetConfig, SyssetConfig,
User, User
MarkRule
} from '../model'; } from '../model';
import { GetSyncData } from '../utils/table/Operation'; import { GetSyncData } from '../utils/table/Operation';
import dayTs from '../utils/Date'; import dayTs from '../utils/Date';
@ -385,8 +376,8 @@ struct Index {
systemParm.txt3 = systemParm.TXT3!; systemParm.txt3 = systemParm.TXT3!;
} }
// const { no1, no2, no3, } = systemParm; // const { no1, no2, no3, } = systemParm;
const txt1 = decodeURI(systemParm.txt1) const txt1 = decodeURI(systemParm.txt1 || "")
const txt2 = decodeURI(systemParm.txt2) const txt2 = decodeURI(systemParm.txt2 || "")
const no1 = systemParm.no1; const no1 = systemParm.no1;
const no2 = systemParm.no2; const no2 = systemParm.no2;
@ -395,7 +386,7 @@ struct Index {
//获取当前考车的no2 //获取当前考车的no2
if (systemParm.no1 == "3" && systemParm.no3 == "1") { if (systemParm.no1 == "3" && systemParm.no3 == "1") {
if (txt1 === this.carName) { if (txt1 === this.carName) {
carNo = systemParm.no2 carNo = systemParm?.no2 || ""
this.carlist = carNo this.carlist = carNo
} }
} }
@ -406,28 +397,28 @@ struct Index {
} }
//根据车型获取应行驶里程数 //根据车型获取应行驶里程数
if (systemParm.no1 == "3" && systemParm.no3 == "15" && carNo === systemParm.no2) { if (systemParm.no1 == "3" && systemParm.no3 == "15" && carNo === systemParm.no2) {
this.examMileage = ((decodeURI(systemParm.txt1)) || '').split('^')[0]; this.examMileage = ((decodeURI(systemParm.txt1 || "")) || '').split('^')[0];
} }
//获取当前考车的考试项目 //获取当前考车的考试项目
if (carNo !== '' && systemParm.no1 == "3" && systemParm.no2 == carNo && systemParm.no3 == "10") { if (carNo !== '' && systemParm.no1 == "3" && systemParm.no2 == carNo && systemParm.no3 == "10") {
allItems = decodeURIComponent(systemParm.txt1).split(',').filter(txt => txt !== '') allItems = decodeURIComponent(systemParm.txt1 || "").split(',').filter(txt => txt !== '')
console.info('surenjun', JSON.stringify(allItems)) console.info('surenjun', JSON.stringify(allItems))
} }
if ( if (
//科目二获取项目 //科目二获取项目
(this.examSubject == "2" && allItems.length && systemParm.no1 == '6' && allItems.includes(systemParm.no2)) (this.examSubject == "2" && allItems.length && systemParm.no1 == '6' && allItems.includes(systemParm?.no2 || ""))
|| ||
//科目三获取项目 //科目三获取项目
(this.examSubject == "3" && systemParm.no1 == "6") (this.examSubject == "3" && systemParm.no1 == "6")
) { ) {
const name = decodeURI(systemParm.txt1) const name = decodeURI(systemParm.txt1 || "")
//小车过滤掉 夜间模拟行驶 //小车过滤掉 夜间模拟行驶
if (sCarTypes.includes(this.carType) && name === '夜间行驶') { if (sCarTypes.includes(this.carType) && name === '夜间行驶') {
return return
} }
const currentProject: ProjectInfo = { const currentProject: ProjectInfo = {
name, name,
abbreviation: decodeURI(systemParm.txt3), abbreviation: decodeURI(systemParm.txt3 || ""),
projectCode: no2, projectCode: no2,
projectCodeCenter: txt2, projectCodeCenter: txt2,
//是否是必考 加减档设置成非必考 //是否是必考 加减档设置成非必考
@ -456,9 +447,9 @@ struct Index {
'NO1': Number(systemParm.no1), 'NO1': Number(systemParm.no1),
'NO2': Number(systemParm.no2), 'NO2': Number(systemParm.no2),
'NO3': Number(systemParm.no3), 'NO3': Number(systemParm.no3),
'TXT1': decodeURIComponent(systemParm.txt1), 'TXT1': decodeURIComponent(systemParm.txt1 || ""),
'TXT2': decodeURIComponent(systemParm.txt2), 'TXT2': decodeURIComponent(systemParm.txt2 || ""),
'TXT3': decodeURIComponent(systemParm.txt3), 'TXT3': decodeURIComponent(systemParm.txt3 || ""),
}) })
}) })
const projects = this.projects; const projects = this.projects;
@ -479,7 +470,7 @@ struct Index {
//只记录考试项目的模型 //只记录考试项目的模型
const projectsObj = this.projectsObj const projectsObj = this.projectsObj
cdsbParams.forEach((cdsb) => { cdsbParams.forEach((cdsb) => {
const key = decodeURI(cdsb.itemsno) const key = decodeURI(cdsb.itemsno || "")
const newKey = key.split('~').join('_') const newKey = key.split('~').join('_')
const xmdm = Number(key.split('~')[0]) const xmdm = Number(key.split('~')[0])
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
@ -504,8 +495,8 @@ struct Index {
const carlist = this.carlist; const carlist = this.carlist;
const projectsObj = this.projectsObj const projectsObj = this.projectsObj
infoParams.forEach((info) => { infoParams.forEach((info) => {
const key = decodeURI(info.itemsno); const key = decodeURI(info.itemsno || "");
const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist).split(',') || []); const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist || "").split(',') || []);
const newKey = key.split('~').join('_') const newKey = key.split('~').join('_')
const xmdm = Number(key.split('~')[0]) const xmdm = Number(key.split('~')[0])
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)

View File

@ -125,6 +125,42 @@ struct UserInfo {
} }
@State startExam: boolean = false @State startExam: boolean = false
@State singlePlay: boolean = false @State singlePlay: boolean = false
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
private title = ''
private type = '2'
errorDialog: CustomDialogController = new CustomDialogController({
builder: errorMsgDialog({
title: this.title,
type: this.type,
cancel: () => {
},
confirm: () => {
}
}),
customStyle: true,
alignment: DialogAlignment.Center,
},
)
private filePhoto!: FilePhoto
// 过程照片拍照
getPhoto = async () => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const photoBase64: string = (await this.filePhoto.getPhoto()) || "";
return photoBase64
}
}
private avPlayer!: VoiceAnnounce
private labelBlocks: LabelBlockType[] = [
{ label: '考生姓名', key: 'xm' },
{ label: '身份证号', key: 'sfzmhm' },
{ label: ' 流 水 号 ', key: 'lsh' },
{ label: '考试路线', key: 'ksxl' },
{ label: '待考次数', key: 'kssycs' },
{ label: '考试员名', key: 'ksy2' },
]
//开始考试准备 //开始考试准备
prePareExam = async () => { prePareExam = async () => {
if (this.ksksLimit) { if (this.ksksLimit) {
@ -171,42 +207,6 @@ struct UserInfo {
} }
} }
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
private title = ''
private type = '2'
errorDialog: CustomDialogController = new CustomDialogController({
builder: errorMsgDialog({
title: this.title,
type: this.type,
cancel: () => {
},
confirm: () => {
}
}),
customStyle: true,
alignment: DialogAlignment.Center,
},
)
private filePhoto!: FilePhoto
// 过程照片拍照
getPhoto = async () => {
//单机模式返回空照片
if (this.singlePlay) {
return ''
} else {
const photoBase64: string = (await this.filePhoto.getPhoto()) || "";
return photoBase64
}
}
private avPlayer!: VoiceAnnounce
private labelBlocks: LabelBlockType[] = [
{ label: '考生姓名', key: 'xm' },
{ label: '身份证号', key: 'sfzmhm' },
{ label: ' 流 水 号 ', key: 'lsh' },
{ label: '考试路线', key: 'ksxl' },
{ label: '待考次数', key: 'kssycs' },
{ label: '考试员名', key: 'ksy2' },
]
aboutToAppear() { aboutToAppear() {
this.avPlayer = new VoiceAnnounce(this.context); this.avPlayer = new VoiceAnnounce(this.context);
@ -682,7 +682,7 @@ struct UserInfo {
// } // }
// } // }
for (const key of Object.keys(res.getExaminationStudentInfoRsp.body)) { for (const key of Object.keys(res.getExaminationStudentInfoRsp.body)) {
const a: User[] | User = res.getExaminationStudentInfoRsp.body[key]; const a: User[] | User = Reflect.get(res.getExaminationStudentInfoRsp.body, key);
if (Array.isArray(a)) { if (Array.isArray(a)) {
dataList = a; dataList = a;
} else { } else {

View File

@ -1,4 +1,4 @@
import { User } from "../../model"; import { User } from '../../model';
export const GetCurrentUserKeyValue = (user: User, key: string): string => { export const GetCurrentUserKeyValue = (user: User, key: string): string => {
switch (key) { switch (key) {
@ -13,7 +13,7 @@ export const GetCurrentUserKeyValue = (user: User, key: string): string => {
case "ksy2": case "ksy2":
return user.ksy2; return user.ksy2;
case "id": case "id":
return user.id; return user.id!;
case "kszp": case "kszp":
return user.kszp; return user.kszp;
case "ksmjzp": case "ksmjzp":
@ -25,7 +25,7 @@ export const GetCurrentUserKeyValue = (user: User, key: string): string => {
case "kchp": case "kchp":
return user.kchp; return user.kchp;
case "kscx": case "kscx":
return user.kscx; return user.kscx!;
case "ksdd": case "ksdd":
return user.ksdd; return user.ksdd;
case "kssycs": case "kssycs":

View File

@ -16,6 +16,7 @@ interface RequestOption {
function xmlToJSON(target: string): object { function xmlToJSON(target: string): object {
console.log("进入xml解析")
let conv = new convertxml.ConvertXML() let conv = new convertxml.ConvertXML()
const result: object = conv.convertToJSObject(target, { const result: object = conv.convertToJSObject(target, {
trim: false, trim: false,
@ -31,6 +32,7 @@ function xmlToJSON(target: string): object {
nameKey: "_name", nameKey: "_name",
elementsKey: "_elements", elementsKey: "_elements",
}) })
console.log("xml解析完成", JSON.stringify(result))
return transfer(result['_elements']) return transfer(result['_elements'])
} }
@ -131,6 +133,7 @@ export default function Request<T extends RequestResult>(options: RequestOption)
}).then(async data => { }).then(async data => {
console.log(RequestTag, options.url, "返回的数据", JSON.stringify(data)) console.log(RequestTag, options.url, "返回的数据", JSON.stringify(data))
let result = options.xml ? xmlToJSON(data.result as string) : data.result let result = options.xml ? xmlToJSON(data.result as string) : data.result
console.log("结束xml解析")
let resObj: object = new Object() let resObj: object = new Object()
if (typeof result === 'string') { if (typeof result === 'string') {
result = JSON.parse(result) result = JSON.parse(result)

View File

@ -1,4 +1,4 @@
import { InitializeTheCentralTableType, ResponseDataType, User } from '../../model'; import { InitializeTheCentralTableType, PublicInfoType, RecordType, ResponseDataType } from '../../model';
import DB, { ColumnInfo, ColumnType } from '../DbSql'; import DB, { ColumnInfo, ColumnType } from '../DbSql';
import { CenterMap, ParameterPlatform, RemappingTableName } from './Relationship'; import { CenterMap, ParameterPlatform, RemappingTableName } from './Relationship';
import { BusinessError } from '@ohos.base'; import { BusinessError } from '@ohos.base';
@ -19,7 +19,7 @@ export async function InitTable() {
} }
// 插表操作 // 插表操作
export function SqlInsertTable(tableName: string, data: Array<User>, delFlag = true): Promise<boolean> { export function SqlInsertTable(tableName: string, data: Array<RecordType>, delFlag = true): Promise<boolean> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
data.forEach((element, index) => { data.forEach((element, index) => {
element.id = !delFlag ? `${index + data.length}` : `${index}` element.id = !delFlag ? `${index + data.length}` : `${index}`
@ -51,7 +51,7 @@ export function SqlInsertTable(tableName: string, data: Array<User>, delFlag = t
// TODO 后续废弃这个方法,直接调用SqlInsertTable // TODO 后续废弃这个方法,直接调用SqlInsertTable
// 依据数组和表名更新sql表 // 依据数组和表名更新sql表
export function UpdateTableByArray(tableName: string, arr: Array<User>): Promise<boolean> { export function UpdateTableByArray(tableName: string, arr: Array<RecordType>): Promise<boolean> {
return SqlInsertTable(tableName, arr) return SqlInsertTable(tableName, arr)
} }
@ -126,6 +126,7 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
host: params.host host: params.host
} }
const res: ResponseDataType = await initialization(str) const res: ResponseDataType = await initialization(str)
console.log("解析完成")
if (!res || !res.initializationRsp || res.initializationRsp.head.resultCode === "1") { if (!res || !res.initializationRsp || res.initializationRsp.head.resultCode === "1") {
resolve(false); resolve(false);
} }
@ -134,12 +135,12 @@ export async function InitializeTheCentralTable(params: InitializeTheCentralTabl
if (CenterMap[key]) { if (CenterMap[key]) {
continue continue
} }
// TODO 后续替换类型 let arrList: Array<RecordType> | RecordType = []
let arrList: ESObject[] = [] let value: PublicInfoType = Reflect.get(res.initializationRsp.body, key)
if (res.initializationRsp.body[key] instanceof Array) { if (value.record instanceof Array) {
arrList = res.initializationRsp.body[key] arrList = value.record
} else { } else {
arrList.push(res.initializationRsp.body[key]) arrList.push(value.record)
} }
const folderPath = await fileUtil.initFolder(`/config/tableList`); const folderPath = await fileUtil.initFolder(`/config/tableList`);
fileUtil.addFile(`${folderPath}/${RemappingTableName.get(key)}.txt`, JSON.stringify(arrList)) fileUtil.addFile(`${folderPath}/${RemappingTableName.get(key)}.txt`, JSON.stringify(arrList))