fix: 润和兼容性更改
This commit is contained in:
parent
6d3a5d2360
commit
1fb5fa23b9
@ -5,9 +5,9 @@
|
|||||||
"name": "default",
|
"name": "default",
|
||||||
"material": {
|
"material": {
|
||||||
"certpath": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.cer",
|
"certpath": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.cer",
|
||||||
"storePassword": "0000001BD807731D6FB9F044E3DF0E0429F4BB4214FE1608E25B4197041FBF36DDA3C6760585312F2864B6",
|
"storePassword": "0000001B42BCAC6B534ABB3B488F5C45764278201EE92A007F988939EC561EEB8ED64F737B8A11A7A72A1E",
|
||||||
"keyAlias": "debugKey",
|
"keyAlias": "debugKey",
|
||||||
"keyPassword": "0000001BFA38BF5235541496B5FF9ED9FFA764AB53FABC873D21DC230060209C2FF24ACE5DA09413B0C138",
|
"keyPassword": "0000001B2A149F63C38A6F5B972EC903EB0ADAB7978BA6C33B8E460C7353BD0BC2248776AB2FD2AE009A98",
|
||||||
"profile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p7b",
|
"profile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p7b",
|
||||||
"signAlg": "SHA256withECDSA",
|
"signAlg": "SHA256withECDSA",
|
||||||
"storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p12"
|
"storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p12"
|
||||||
|
|||||||
@ -427,7 +427,8 @@ export struct JudgePage {
|
|||||||
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(this.projectsObj, xmdm)
|
const data: ProjectInfos = JSON.parse(JSON.stringify(this.projectsObj))
|
||||||
|
const currentProject: ProjectInfo = Reflect.get(data, xmdm)
|
||||||
if (currentProject && (carlistArr.length == 0 || carlistArr.includes(this.carlist))) {
|
if (currentProject && (carlistArr.length == 0 || carlistArr.includes(this.carlist))) {
|
||||||
Reflect.set(this.itemInfoObj!, newKey, {
|
Reflect.set(this.itemInfoObj!, newKey, {
|
||||||
modelKey: newKey,
|
modelKey: newKey,
|
||||||
@ -461,7 +462,7 @@ export struct JudgePage {
|
|||||||
const examItems: string | undefined = currentParams?.examItems;
|
const examItems: string | undefined = currentParams?.examItems;
|
||||||
// 2024-01-03 16:29:26;0;20300,;2,4^2,4;null;
|
// 2024-01-03 16:29:26;0;20300,;2,4^2,4;null;
|
||||||
if (examItems !== '' && examItems !== undefined) {
|
if (examItems !== '' && examItems !== undefined) {
|
||||||
dConsole.info(JudgeTag, 'surenjun examItems=>', JSON.stringify(examItems))
|
dConsole.info(JudgeTag, 'surenjun examItems=>', examItems)
|
||||||
const examItemsArrs = examItems.split(';');
|
const examItemsArrs = examItems.split(';');
|
||||||
const startTime = examItemsArrs[0]
|
const startTime = examItemsArrs[0]
|
||||||
const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || []
|
const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || []
|
||||||
|
|||||||
@ -99,11 +99,12 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
|||||||
public async GetJudgeInitData(context: common.UIAbilityContext, markRuleListObj: object, carType: string, carName: string, systemparmArr: SYSTEM_PARAM[], carinfoArr: CAR_INFO[], examSubject: string, itemInfoObj: ItemInfos, judgeConfig: SyssetConfig[], carlist: string, mapPointArr: MAPPOINT[], mapPointItemArr: MAPITEMPOINTITEM[]) {
|
public async GetJudgeInitData(context: common.UIAbilityContext, markRuleListObj: object, carType: string, carName: string, systemparmArr: SYSTEM_PARAM[], carinfoArr: CAR_INFO[], examSubject: string, itemInfoObj: ItemInfos, judgeConfig: SyssetConfig[], carlist: string, mapPointArr: MAPPOINT[], mapPointItemArr: MAPITEMPOINTITEM[]) {
|
||||||
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
||||||
const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3'
|
const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3'
|
||||||
|
dConsole.log(JudgeTag, "itemInfoObj", itemInfoObj)
|
||||||
let allitems: ItemInfo[] = [];
|
let allitems: ItemInfo[] = [];
|
||||||
if (examSubject == '2' && itemInfoObj) {
|
if (examSubject == '2' && itemInfoObj) {
|
||||||
allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => {
|
allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => {
|
||||||
const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey);
|
// const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey);
|
||||||
|
const cdsb: CDSBInfo = Object.entries(itemInfoObj).find((arr: Array<string>) => arr[0] === cdsbKey)![1]
|
||||||
const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context)
|
const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context)
|
||||||
const temp: ItemInfo = {
|
const temp: ItemInfo = {
|
||||||
xmdm: cdsb?.xmdm || 0,
|
xmdm: cdsb?.xmdm || 0,
|
||||||
@ -298,7 +299,6 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
|
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
|
||||||
|
|
||||||
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
|
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
|
||||||
const trajectoryPath = JudgeConfig.trajectoryPath;
|
const trajectoryPath = JudgeConfig.trajectoryPath;
|
||||||
let strArr: string[] = [];
|
let strArr: string[] = [];
|
||||||
|
|||||||
@ -156,14 +156,6 @@ struct UserInfoPage {
|
|||||||
@State singlePlay: boolean = false
|
@State singlePlay: boolean = false
|
||||||
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||||
private avPlayer!: VoiceAnnounce
|
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 () => {
|
||||||
dConsole.log(StartExamTag, 'prePareExam')
|
dConsole.log(StartExamTag, 'prePareExam')
|
||||||
@ -180,9 +172,12 @@ struct UserInfoPage {
|
|||||||
if (this.singlePlay) {
|
if (this.singlePlay) {
|
||||||
this.currentUser.id = '0'
|
this.currentUser.id = '0'
|
||||||
dConsole.log(StartExamTag, '开始考试3', this.currentUser)
|
dConsole.log(StartExamTag, '开始考试3', this.currentUser)
|
||||||
SqlInsertTable('USER', [this.currentUser]).catch((e: BusinessError) => {
|
try {
|
||||||
dConsole.log(StartExamTag, "error", JSON.stringify(e))
|
// let data: Array<User> = JSON.parse(JSON.stringify([this.currentUser]))
|
||||||
})
|
await SqlInsertTable('USER', [this.currentUser])
|
||||||
|
} catch (e) {
|
||||||
|
dConsole.error(StartExamTag, '开始考试插入用户表失败', JSON.stringify(e))
|
||||||
|
}
|
||||||
// 初始化开始考试过程数据文件夹
|
// 初始化开始考试过程数据文件夹
|
||||||
InitializeExamProcessData(this.currentUser)
|
InitializeExamProcessData(this.currentUser)
|
||||||
dConsole.log(StartExamTag, '开始考试4')
|
dConsole.log(StartExamTag, '开始考试4')
|
||||||
@ -213,6 +208,14 @@ struct UserInfoPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private labelBlocks: LabelBlockType[] = [
|
||||||
|
{ label: '考生姓名', key: 'xm' },
|
||||||
|
{ label: '身份证号', key: 'sfzmhm' },
|
||||||
|
{ label: ' 流 水 号 ', key: 'lsh' },
|
||||||
|
{ label: '考试路线', key: 'ksxl' },
|
||||||
|
{ label: '待考次数', key: 'kssycs' },
|
||||||
|
{ label: '考试员名', key: 'ksy2' },
|
||||||
|
]
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
this.avPlayer = new VoiceAnnounce(this.context);
|
this.avPlayer = new VoiceAnnounce(this.context);
|
||||||
|
|||||||
@ -109,11 +109,11 @@ export function NumberToByteArray(number: number | string, len: number): number[
|
|||||||
return arrBytes;
|
return arrBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 将字符串填充为指定长度的字符串,前面补0
|
* 将字符串填充为指定长度的字符串,前面补0
|
||||||
* @param str 要填充的字符串或数字
|
* @param str 要填充的字符串或数字
|
||||||
* @param len 目标长度
|
* @param len 目标长度
|
||||||
* @return 返回填充后的字符串
|
* @return 返回填充后的字符串
|
||||||
*/
|
*/
|
||||||
export function FillZero(str: string | number, len: number): string {
|
export function FillZero(str: string | number, len: number): string {
|
||||||
str = str.toString();
|
str = str.toString();
|
||||||
@ -176,10 +176,10 @@ export function DeepClone<T extends Object>(target: T): T {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 检查文件或目录是否存在
|
* 检查文件或目录是否存在
|
||||||
* @param path 文件或目录的路径
|
* @param path 文件或目录的路径
|
||||||
* @return 返回一个 Promise,解析为 true 如果存在,否则为 false
|
* @return 返回一个 Promise,解析为 true 如果存在,否则为 false
|
||||||
*/
|
*/
|
||||||
export function IsExit(path: string): Promise<boolean> {
|
export function IsExit(path: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -222,6 +222,8 @@ export function CreateDir(path: string): Promise<boolean> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 写文件
|
* 写文件
|
||||||
|
* @params fd 文件描述符
|
||||||
|
* @params data 写入的数据
|
||||||
*/
|
*/
|
||||||
export function EditFile(fd: number, data: string): Promise<boolean> {
|
export function EditFile(fd: number, data: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -252,10 +254,25 @@ export function CreateFile(path: string): Promise<number> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 将秒数转换为灵活的时间格式(HH:MM:SS)
|
* 读取文件内容
|
||||||
* @param seconds 要转换的秒数
|
* @params path 文件具体路径
|
||||||
* @return 返回格式化后的时间字符串
|
*/
|
||||||
|
export function ReadFileContent(path: string): Promise<string> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const data = fs.readTextSync(path)
|
||||||
|
resolve(data)
|
||||||
|
} catch (e) {
|
||||||
|
reject(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将秒数转换为灵活的时间格式(HH:MM:SS)
|
||||||
|
* @param seconds 要转换的秒数
|
||||||
|
* @return 返回格式化后的时间字符串
|
||||||
*/
|
*/
|
||||||
export function FormatTimeFlexible(seconds: number): string {
|
export function FormatTimeFlexible(seconds: number): string {
|
||||||
if (seconds < 0) {
|
if (seconds < 0) {
|
||||||
@ -291,10 +308,10 @@ export function ApplyForAuthorization(context: Context, permissionList: Array<Pe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 使用权限
|
* 使用权限
|
||||||
* @param context 上下文
|
* @param context 上下文
|
||||||
* @return 返回一个 Promise,解析为 true 如果授权成功,否则为 false
|
* @return 返回一个 Promise,解析为 true 如果授权成功,否则为 false
|
||||||
*/
|
*/
|
||||||
export async function UseAuth(context: common.UIAbilityContext): Promise<boolean> {
|
export async function UseAuth(context: common.UIAbilityContext): Promise<boolean> {
|
||||||
const permissions: Array<Permissions> = [
|
const permissions: Array<Permissions> = [
|
||||||
@ -351,4 +368,5 @@ export const GetPhotoBase64 = async (context: common.UIAbilityContext): Promise<
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import testNapi from '@ohos.hiserialsdk';
|
|
||||||
import HiSerialSDK from '@ohos.hiserialsdk';
|
import HiSerialSDK from '@ohos.hiserialsdk';
|
||||||
import { SerialPortTag } from '../config';
|
import { SerialPortTag } from '../config';
|
||||||
|
|
||||||
@ -8,7 +7,7 @@ import { SerialPortTag } from '../config';
|
|||||||
*/
|
*/
|
||||||
export const OpenSerialPort = (serialPort: string) => {
|
export const OpenSerialPort = (serialPort: string) => {
|
||||||
return new Promise<number>((resolve, reject) => {
|
return new Promise<number>((resolve, reject) => {
|
||||||
testNapi.SerialOpenAsync(serialPort, (value: number) => {
|
HiSerialSDK.SerialOpenAsync(serialPort, (value: number) => {
|
||||||
if (value === -1) {
|
if (value === -1) {
|
||||||
console.error(SerialPortTag, "打开串口失败!")
|
console.error(SerialPortTag, "打开串口失败!")
|
||||||
reject(-1)
|
reject(-1)
|
||||||
@ -28,7 +27,7 @@ export const OpenSerialPort = (serialPort: string) => {
|
|||||||
export const InitSerialPortData =
|
export const InitSerialPortData =
|
||||||
async (fd: number, speed: number) => {
|
async (fd: number, speed: number) => {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
testNapi.SerialSetAsync(fd, speed, 0, 8, 1, 0x4e, (value: number) => {
|
HiSerialSDK.SerialSetAsync(fd, speed, 0, 8, 1, 0x4e, (value: number) => {
|
||||||
// 0 成功 -1失败
|
// 0 成功 -1失败
|
||||||
if (value === 0) {
|
if (value === 0) {
|
||||||
console.log(SerialPortTag, "初始化成功!")
|
console.log(SerialPortTag, "初始化成功!")
|
||||||
@ -49,9 +48,10 @@ export const InitSerialPortData =
|
|||||||
* @returns Promise<number> 成功返回发送的字节数,失败返回-1
|
* @returns Promise<number> 成功返回发送的字节数,失败返回-1
|
||||||
*/
|
*/
|
||||||
export const SendSerialPortData = (fd: number, data: number[]) => {
|
export const SendSerialPortData = (fd: number, data: number[]) => {
|
||||||
// console.log(SerialPortTag, "wzj-----发送数据")
|
console.log(SerialPortTag, "wzj-----发送数据")
|
||||||
return new Promise<number>((resolve, reject) => {
|
return new Promise<number>((resolve, reject) => {
|
||||||
testNapi.SerialSendAsync(fd, data, (value: number) => {
|
HiSerialSDK.SerialSendAsync(fd, data, (value: number) => {
|
||||||
|
console.log(SerialPortTag, "发送数据完成!")
|
||||||
if (value === -1) {
|
if (value === -1) {
|
||||||
console.error(SerialPortTag, "发送失败!")
|
console.error(SerialPortTag, "发送失败!")
|
||||||
reject(-1)
|
reject(-1)
|
||||||
@ -68,9 +68,9 @@ export const SendSerialPortData = (fd: number, data: number[]) => {
|
|||||||
* @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1
|
* @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1
|
||||||
*/
|
*/
|
||||||
export const ReceiveSerialPortData = (fd: number, timeout: number,) => {
|
export const ReceiveSerialPortData = (fd: number, timeout: number,) => {
|
||||||
// console.log(SerialPortTag, "wzj-----接受数据")
|
console.log(SerialPortTag, "wzj-----接受数据")
|
||||||
return new Promise<HiSerialSDK.receiveInfo>((resolve) => {
|
return new Promise<HiSerialSDK.receiveInfo>((resolve) => {
|
||||||
testNapi.SerialRecvAsync(fd, timeout, (value: HiSerialSDK.receiveInfo) => {
|
HiSerialSDK.SerialRecvAsync(fd, timeout, (value: HiSerialSDK.receiveInfo) => {
|
||||||
resolve(value)
|
resolve(value)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -78,13 +78,13 @@ export const ReceiveSerialPortData = (fd: number, timeout: number,) => {
|
|||||||
|
|
||||||
// 主动接受数据
|
// 主动接受数据
|
||||||
export const ReceiveSerialPortDataBySelf = (fd: number, callback: Function) => {
|
export const ReceiveSerialPortDataBySelf = (fd: number, callback: Function) => {
|
||||||
testNapi.SerialListenCallbackSet(fd, callback)
|
HiSerialSDK.SerialListenCallbackSet(fd, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消主动接受
|
// 取消主动接受
|
||||||
export const CancelReceiveSerialPortData = async (fd: number) => {
|
export const CancelReceiveSerialPortData = async (fd: number) => {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
let result: number = testNapi.SerialListenCallbackCancel(fd)
|
let result: number = HiSerialSDK.SerialListenCallbackCancel(fd)
|
||||||
if (result === 0) {
|
if (result === 0) {
|
||||||
resolve(true)
|
resolve(true)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -82,7 +82,7 @@ export default class UdpClient {
|
|||||||
address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1
|
address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log(UDPTag, "udp发送成功", JSON.stringify(res))
|
// console.log(UDPTag, "udp发送成功", JSON.stringify(res))
|
||||||
}).catch((e: BusinessError) => {
|
}).catch((e: BusinessError) => {
|
||||||
console.error(UDPTag, "udp发送失败", JSON.stringify(e))
|
console.error(UDPTag, "udp发送失败", JSON.stringify(e))
|
||||||
})
|
})
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class CenterUDPBusiness {
|
|||||||
console.log(CenterUdpTag, "心跳", JSON.stringify(this.carInfo))
|
console.log(CenterUdpTag, "心跳", JSON.stringify(this.carInfo))
|
||||||
// 组装消息,一秒发送一次
|
// 组装消息,一秒发送一次
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
console.log(CenterUdpTag, "发送心跳")
|
// console.log(CenterUdpTag, "发送心跳")
|
||||||
// 生成流水号
|
// 生成流水号
|
||||||
SerialNumberInstance.generate()
|
SerialNumberInstance.generate()
|
||||||
// console.log(CenterUdpTag, "流水号生成")
|
// console.log(CenterUdpTag, "流水号生成")
|
||||||
|
|||||||
@ -19,8 +19,6 @@ import { SerialNumberInstance } from '../SerialNumber';
|
|||||||
import { GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils';
|
import { GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils';
|
||||||
import { testKm2Items, testKm3Items } from '../../mock';
|
import { testKm2Items, testKm3Items } from '../../mock';
|
||||||
|
|
||||||
// import { examCalcGpsDistance } from '../../pages/Judge/JudgeUtils';
|
|
||||||
|
|
||||||
|
|
||||||
class JudgeUdpBusiness {
|
class JudgeUdpBusiness {
|
||||||
private static instance: JudgeUdpBusiness
|
private static instance: JudgeUdpBusiness
|
||||||
|
|||||||
@ -34,7 +34,10 @@ export function SqlInsertTable(tableName: string, data: Array<RecordType>, delFl
|
|||||||
const columns: string = columnsData?.filter((column) => column !== "id").join(",") || "";
|
const columns: string = columnsData?.filter((column) => column !== "id").join(",") || "";
|
||||||
const values = data.map(item => {
|
const values = data.map(item => {
|
||||||
const value = columnsData?.filter(column => column !== "id")
|
const value = columnsData?.filter(column => column !== "id")
|
||||||
.map((column) => `'${Reflect.get(item, column) || ""}'`)
|
.map((column) => {
|
||||||
|
// return `'${Reflect.get(item, column) || ""}'`
|
||||||
|
return `'${Object.entries(item).find((keyArr: Array<string>) => keyArr[0] === column)?.[1] || ""}'`
|
||||||
|
})
|
||||||
.join(",")
|
.join(",")
|
||||||
return `(${value})`
|
return `(${value})`
|
||||||
}).join(",")
|
}).join(",")
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// 处理worker线程的消息tcp拿差分改正数,udp给后置机
|
// 处理worker线程的消息tcp拿差分改正数,udp给后置机
|
||||||
import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker';
|
import worker, { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope } from '@ohos.worker';
|
||||||
import { WorkerTag } from '../config';
|
import { SerialPortTag, WorkerTag } from '../config';
|
||||||
import {
|
import {
|
||||||
CenterCallBackMsgType,
|
CenterCallBackMsgType,
|
||||||
EnvironmentConfigurationType,
|
EnvironmentConfigurationType,
|
||||||
@ -10,14 +10,14 @@ import {
|
|||||||
} from '../model';
|
} from '../model';
|
||||||
import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness';
|
import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness';
|
||||||
import { DifferentialSignal } from '../utils/business/DifferentialSignal';
|
import { DifferentialSignal } from '../utils/business/DifferentialSignal';
|
||||||
|
import { JudgeUdpBusinessInstance } from '../utils/business/JudgeUdpBusiness';
|
||||||
import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness';
|
import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness';
|
||||||
import { SerialPortService } from '../utils/business/SerialPortService';
|
import { SerialPortService } from '../utils/business/SerialPortService';
|
||||||
|
|
||||||
const workerPort: ThreadWorkerGlobalScope = worker.workerPort;
|
const workerPort: ThreadWorkerGlobalScope = worker.workerPort;
|
||||||
|
|
||||||
|
|
||||||
workerPort.onmessage = (e: MessageEvents) => {
|
workerPort.onmessage = (e: MessageEvents) => {
|
||||||
console.log(WorkerTag, `Worker received message: ${e.data}`);
|
console.log(WorkerTag, `Worker收到主线程消息: ${e.data}`)
|
||||||
const result: WorkerMessage = JSON.parse(e.data);
|
const result: WorkerMessage = JSON.parse(e.data);
|
||||||
initFn(result)
|
initFn(result)
|
||||||
// TODO 内部已经实现,外部未实现
|
// TODO 内部已经实现,外部未实现
|
||||||
@ -39,7 +39,7 @@ workerPort.onmessage = (e: MessageEvents) => {
|
|||||||
// 初始化函数
|
// 初始化函数
|
||||||
function initFn(result: WorkerMessage) {
|
function initFn(result: WorkerMessage) {
|
||||||
// 初始化差分校正TCP
|
// 初始化差分校正TCP
|
||||||
DifferentialSignal.init(result.config);
|
DifferentialSignal.init(result.config)
|
||||||
// 定时发送TCP消息
|
// 定时发送TCP消息
|
||||||
DifferentialSignal.sendData()
|
DifferentialSignal.sendData()
|
||||||
// 初始化后置机UDP
|
// 初始化后置机UDP
|
||||||
@ -70,7 +70,7 @@ function getDataFn(config: EnvironmentConfigurationType) {
|
|||||||
// 需要观察
|
// 需要观察
|
||||||
// console.log(WorkerTag, "后置机消息", data)
|
// console.log(WorkerTag, "后置机消息", data)
|
||||||
const res = await SerialPortService.getData()
|
const res = await SerialPortService.getData()
|
||||||
// console.log(SerialPortTag, "档位原始数据", res)
|
console.log(SerialPortTag, "档位原始数据", res)
|
||||||
if (res.length > 0) {
|
if (res.length > 0) {
|
||||||
const dataArray = data.split(",");
|
const dataArray = data.split(",");
|
||||||
// 替换data的第28位
|
// 替换data的第28位
|
||||||
@ -113,7 +113,7 @@ function closedFn(result: WorkerMessage) {
|
|||||||
|
|
||||||
|
|
||||||
workerPort.onmessageerror = (e: MessageEvents) => {
|
workerPort.onmessageerror = (e: MessageEvents) => {
|
||||||
console.log(WorkerTag, `Worker received message error: ${e.data}`);
|
console.log(WorkerTag, `Worker received message error: ${e.data}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user