fix: 济南后置机方案
This commit is contained in:
parent
ca44a19722
commit
c2a1a9d760
@ -2,6 +2,11 @@
|
|||||||
"apiType": 'stageMode',
|
"apiType": 'stageMode',
|
||||||
"buildOption": {
|
"buildOption": {
|
||||||
"externalNativeOptions": {
|
"externalNativeOptions": {
|
||||||
|
"abiFilters": [
|
||||||
|
"arm64-v8a",
|
||||||
|
"armeabi-v7a",
|
||||||
|
"x86_64"
|
||||||
|
],
|
||||||
"path": "./src/main/cpp/CMakeLists.txt",
|
"path": "./src/main/cpp/CMakeLists.txt",
|
||||||
"arguments": "",
|
"arguments": "",
|
||||||
"cppFlags": "",
|
"cppFlags": "",
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { NewTcpClient, XmlToJson } from '../common/utils/new/tcp'
|
|
||||||
import request from "../common/utils/request"
|
import request from "../common/utils/request"
|
||||||
import tempRequest from '../common/utils/tempRequest'
|
import tempRequest from '../common/utils/tempRequest'
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { getSyncData } from '../common/service/initable';
|
import { getSyncData } from '../common/service/initable';
|
||||||
import request from '../common/utils/request';
|
import request from '../common/utils/request';
|
||||||
import FileUtil from '../common/utils/File';
|
import FileUtil from '../common/utils/File';
|
||||||
import { NewTcpClient, XmlToJson } from '../common/utils/new/tcp';
|
import { HandleCenterCode, NewTcpClient, XmlToJson } from '../common/utils/new/tcp';
|
||||||
|
import { PrintStr } from '../common/utils/tools';
|
||||||
|
|
||||||
let baseHost = globalThis.host;
|
let baseHost = globalThis.host;
|
||||||
|
|
||||||
@ -45,37 +46,64 @@ export default async function writeObjectOutNew(data, filePath): Promise<WR> {
|
|||||||
console.info('surenjun', '调用新监管')
|
console.info('surenjun', '调用新监管')
|
||||||
let temp
|
let temp
|
||||||
try {
|
try {
|
||||||
if (jkid === "17C51") {
|
// if (jkid === "17C51") {
|
||||||
temp = await request({
|
// temp = await request({
|
||||||
host: globalThis.JGHOST,
|
// host: globalThis.JGHOST,
|
||||||
method: 'post',
|
// method: 'post',
|
||||||
//是否是新中心
|
// //是否是新中心
|
||||||
isNewCenter: true,
|
// isNewCenter: true,
|
||||||
xml: true,
|
// xml: true,
|
||||||
url: '/dems_ws/services/TmriOutAccess?wsdl',
|
// url: '/dems_ws/services/TmriOutAccess?wsdl',
|
||||||
data: `<?xml version="1.0"?>
|
// data: `<?xml version="1.0"?>
|
||||||
<SOAP-ENV:Envelope
|
// <SOAP-ENV:Envelope
|
||||||
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
// xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
// xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
|
// xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
>
|
// >
|
||||||
<SOAP-ENV:Body>
|
// <SOAP-ENV:Body>
|
||||||
<writeObjectOut xmlns="http://service.es.doron">
|
// <writeObjectOut xmlns="http://service.es.doron">
|
||||||
<wglb>${wglb}</wglb>
|
// <wglb>${wglb}</wglb>
|
||||||
<jkxlh>${jkxlh}</jkxlh>
|
// <jkxlh>${jkxlh}</jkxlh>
|
||||||
<glbm>${glbm}</glbm>
|
// <glbm>${glbm}</glbm>
|
||||||
<jgbh>${jgbh}</jgbh>
|
// <jgbh>${jgbh}</jgbh>
|
||||||
<sjbs>${sjbs}</sjbs>
|
// <sjbs>${sjbs}</sjbs>
|
||||||
<data>${JSON.stringify(params.data)}</data>
|
// <data>${JSON.stringify(params.data)}</data>
|
||||||
<file>${JSON.stringify(params.file)}</file>
|
// <file>${JSON.stringify(params.file)}</file>
|
||||||
</writeObjectOut>
|
// </writeObjectOut>
|
||||||
</SOAP-ENV:Body>
|
// </SOAP-ENV:Body>
|
||||||
</SOAP-ENV:Envelope>`,
|
// </SOAP-ENV:Envelope>`,
|
||||||
})
|
// })
|
||||||
} else {
|
// } else {
|
||||||
|
temp = await getMessageByEnd(params, basic)
|
||||||
|
console.log("zj result", JSON.stringify(temp))
|
||||||
|
// }
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.log("zj 新监管错误")
|
||||||
|
temp = e
|
||||||
|
}
|
||||||
|
console.log("zj temp message: ", JSON.stringify(temp))
|
||||||
|
if (filePath) {
|
||||||
|
await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(temp) + `\n`);
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMessageByEnd(params, basic) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
PrintStr(params, 100)
|
||||||
|
// 如果超时,抛出错误
|
||||||
|
console.log("zj tcp timeout")
|
||||||
|
reject(new Error("Timeout: No data received within 15 seconds"));
|
||||||
|
}, 15000);
|
||||||
|
const {wglb,jkxlh,glbm,jgbh,sjbs} = basic;
|
||||||
let baseUrl = globalThis.JGHOST ? globalThis.JGHOST : globalThis.host
|
let baseUrl = globalThis.JGHOST ? globalThis.JGHOST : globalThis.host
|
||||||
let key = new Date().getTime()
|
let key = new Date().getTime()
|
||||||
// 走后置机
|
// 走后置机
|
||||||
|
params.file.param = [{
|
||||||
|
field: '', data: ""
|
||||||
|
}]
|
||||||
let data = {
|
let data = {
|
||||||
url: `${baseUrl}/dems_ws/services/TmriOutAccess?wsdl`,
|
url: `${baseUrl}/dems_ws/services/TmriOutAccess?wsdl`,
|
||||||
serialNumber: key,
|
serialNumber: key,
|
||||||
@ -103,36 +131,37 @@ export default async function writeObjectOutNew(data, filePath): Promise<WR> {
|
|||||||
contentType: 'text/xml',
|
contentType: 'text/xml',
|
||||||
isHeartBeat: "0",
|
isHeartBeat: "0",
|
||||||
}
|
}
|
||||||
|
console.log("zj guocheng", JSON.stringify(data))
|
||||||
NewTcpClient.sendMsg(`^#${JSON.stringify(data)}#$`)
|
NewTcpClient.sendMsg(`^#${JSON.stringify(data)}#$`)
|
||||||
NewTcpClient.onMessage((value) => {
|
let cache = ""
|
||||||
console.log("zj value", value)
|
NewTcpClient.onMessage(async (value) => {
|
||||||
// 使用正则表达式提取^#和#$之间的JSON数据
|
console.log("zj onMessage", value)
|
||||||
const jsonDataMatch = value.match(/\^#(.*?)#\$/);
|
// 先找到^#和#$开始结束符号
|
||||||
if (jsonDataMatch && jsonDataMatch[1]) {
|
cache += value
|
||||||
try {
|
let start = cache.indexOf("^#")
|
||||||
const jsonData = JSON.parse(jsonDataMatch[1]);
|
let end = cache.indexOf("#$")
|
||||||
if (Number(jsonData.serialNumber) === Number(key)) {
|
if (start !== -1 && end !== -1) {
|
||||||
temp = XmlToJson(jsonData.data);
|
let message = cache.slice(start + 2, end)
|
||||||
|
cache = cache.slice(end + 2)
|
||||||
|
let tempIndex = message.indexOf("^#")
|
||||||
|
while (tempIndex > -1) {
|
||||||
|
message = message.slice(tempIndex + 2)
|
||||||
|
tempIndex = message.indexOf("^#")
|
||||||
|
}
|
||||||
|
let result: any = JSON.parse(message)
|
||||||
|
if (Number(result.serialNumber) === Number(key) && !result.url) {
|
||||||
|
let temp: any = XmlToJson(result.data)
|
||||||
|
if (temp.Envelope) {
|
||||||
|
console.log("zj accept", JSON.stringify(temp))
|
||||||
|
const msgXml = temp.Envelope.Body.writeObjectOutResponse.return;
|
||||||
|
const dd = HandleCenterCode(msgXml, true);
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
resolve(dd)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to parse JSON data:", error);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log("No JSON data found between ^# and #$");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.log("新监管错误")
|
|
||||||
temp = e
|
|
||||||
}
|
|
||||||
console.log("temp message: ", JSON.stringify(temp))
|
|
||||||
if (filePath) {
|
|
||||||
await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(temp) + `\n`);
|
|
||||||
}
|
|
||||||
return temp
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getParams(jkid, drvexam) {
|
export async function getParams(jkid, drvexam) {
|
||||||
|
|||||||
@ -229,6 +229,7 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
|||||||
const date = time.split(' ')[0]
|
const date = time.split(' ')[0]
|
||||||
let dirName = dir ? dir : date
|
let dirName = dir ? dir : date
|
||||||
rtsp_server.getVideoSnapshot(context, video_uri, fileName, dirName, true, async (err, snapResult) => {
|
rtsp_server.getVideoSnapshot(context, video_uri, fileName, dirName, true, async (err, snapResult) => {
|
||||||
|
console.log("zj photo", snapResult.fileSize.toString())
|
||||||
if (snapResult.result && snapResult.errorCode == 0) {
|
if (snapResult.result && snapResult.errorCode == 0) {
|
||||||
resolve({
|
resolve({
|
||||||
base64: snapResult.dataString,
|
base64: snapResult.dataString,
|
||||||
@ -249,6 +250,7 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteAllPicturesFn() {
|
export async function deleteAllPicturesFn() {
|
||||||
fileHelper.deleteAllPictures();
|
fileHelper.deleteAllPictures();
|
||||||
deleteAllVideos(globalThis.context, photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.VIDEO)
|
deleteAllVideos(globalThis.context, photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.VIDEO)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import Want from '@ohos.app.ability.Want'
|
import Want from '@ohos.app.ability.Want'
|
||||||
import promptAction from '@ohos.promptAction'
|
import promptAction from '@ohos.promptAction'
|
||||||
|
import fileAccess from '@ohos.file.fileAccess'
|
||||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'
|
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'
|
||||||
import common from '@ohos.app.ability.common'
|
import common from '@ohos.app.ability.common'
|
||||||
import fs from '@ohos.file.fs'
|
import fs from '@ohos.file.fs'
|
||||||
@ -103,7 +104,7 @@ export default class FileUtil {
|
|||||||
};
|
};
|
||||||
private context: common.UIAbilityContext
|
private context: common.UIAbilityContext
|
||||||
private wantInfos: Want[]
|
private wantInfos: Want[]
|
||||||
private fileAccessHelper: any
|
private fileAccessHelper: fileAccess.FileAccessHelper
|
||||||
//后续文件路径待替换
|
//后续文件路径待替换
|
||||||
private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files/duolun'
|
private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files/duolun'
|
||||||
private getFilePathList = async (filePath: string, isSdcard: boolean) => {
|
private getFilePathList = async (filePath: string, isSdcard: boolean) => {
|
||||||
@ -127,10 +128,8 @@ export default class FileUtil {
|
|||||||
}
|
}
|
||||||
// 检索文件列表
|
// 检索文件列表
|
||||||
public getSdCardPathList = async () => {
|
public getSdCardPathList = async () => {
|
||||||
//@ts-ignore
|
|
||||||
this.wantInfos = await fileAccess.getFileAccessAbilityInfo();
|
this.wantInfos = await fileAccess.getFileAccessAbilityInfo();
|
||||||
const {wantInfos,context} = this;
|
const {wantInfos,context} = this;
|
||||||
//@ts-ignore
|
|
||||||
const fileAccessHelper = fileAccess.createFileAccessHelper(this.context, this.wantInfos);
|
const fileAccessHelper = fileAccess.createFileAccessHelper(this.context, this.wantInfos);
|
||||||
this.fileAccessHelper = fileAccessHelper;
|
this.fileAccessHelper = fileAccessHelper;
|
||||||
|
|
||||||
@ -177,7 +176,6 @@ export default class FileUtil {
|
|||||||
'ohos.permission.READ_MEDIA',
|
'ohos.permission.READ_MEDIA',
|
||||||
'ohos.permission.WRITE_MEDIA'
|
'ohos.permission.WRITE_MEDIA'
|
||||||
];
|
];
|
||||||
// @ts-ignore
|
|
||||||
this.wantInfos = await fileAccess.getFileAccessAbilityInfo();
|
this.wantInfos = await fileAccess.getFileAccessAbilityInfo();
|
||||||
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager()
|
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager()
|
||||||
atManager.requestPermissionsFromUser(context, permissions, async (code, result) => {
|
atManager.requestPermissionsFromUser(context, permissions, async (code, result) => {
|
||||||
|
|||||||
@ -305,24 +305,24 @@ export default class UdpClientByCenter {
|
|||||||
console.info('surenjun', 'getUDP关闭udp message监听事件 成功')
|
console.info('surenjun', 'getUDP关闭udp message监听事件 成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
message_1Fn = (value) => {
|
message_1Fn = (strachArr) => {
|
||||||
let callback = this.onMessage_1Callback
|
let callback = this.onMessage_1Callback
|
||||||
// 收到的是ArrayBuffer 需要进行转换解析
|
// 收到的是ArrayBuffer 需要进行转换解析
|
||||||
this.plcUdpError = false
|
this.plcUdpError = false
|
||||||
if (value) {
|
if (strachArr) {
|
||||||
let dataView = new DataView(value.message)
|
// let dataView = new DataView(value.message)
|
||||||
let str = ""
|
// let str = ""
|
||||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
// for (let i = 0; i < dataView?.byteLength; ++i) {
|
||||||
let c = String.fromCharCode(dataView?.getUint8(i))
|
// let c = String.fromCharCode(dataView?.getUint8(i))
|
||||||
if (c !== "\n") {
|
// if (c !== "\n") {
|
||||||
str += c
|
// str += c
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
let strachArr = str.split(',')
|
// let strachArr = str.split(',')
|
||||||
if (strachArr[0] != '#DN_GD') {
|
// if (strachArr[0] != '#DN_GD') {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
strachArr[28] = globalThis.chuankoMsg || strachArr[28]
|
strachArr[28] = globalThis.chuankoMsg || strachArr[28]
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import socket from '@ohos.net.socket';
|
import socket from '@ohos.net.socket';
|
||||||
import convertxml from '@ohos.convertxml';
|
import convertxml from '@ohos.convertxml';
|
||||||
|
import util from '@ohos.util';
|
||||||
|
import Prompt from '@system.prompt';
|
||||||
|
|
||||||
class NewTcp {
|
class NewTcp {
|
||||||
private localIp: string = '192.168.7.170'
|
private localIp: string = '192.168.7.170'
|
||||||
@ -7,6 +9,7 @@ class NewTcp {
|
|||||||
private oppositeIp: string = '192.168.7.124'
|
private oppositeIp: string = '192.168.7.124'
|
||||||
private oppositeIpPort: string = '20022'
|
private oppositeIpPort: string = '20022'
|
||||||
private tcp: socket.TCPSocket = null
|
private tcp: socket.TCPSocket = null
|
||||||
|
private cbArr = []
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.init()
|
this.init()
|
||||||
@ -24,6 +27,26 @@ class NewTcp {
|
|||||||
timeout: 6000
|
timeout: 6000
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log('tcp connect success')
|
console.log('tcp connect success')
|
||||||
|
this.tcp.on("message", (value) => {
|
||||||
|
if (value) {
|
||||||
|
let decoder = util.TextDecoder.create()
|
||||||
|
let message = decoder.decodeWithStream(new Uint8Array(value.message))
|
||||||
|
let strArr = message.split(',')
|
||||||
|
// 获取档位信息
|
||||||
|
strArr[28] = globalThis.chuankoMsg || '0'
|
||||||
|
globalThis.udpClient.getCurrentMessage = strArr.toString()
|
||||||
|
this.cbArr.forEach(cb => {
|
||||||
|
cb && cb(strArr.toString())
|
||||||
|
})
|
||||||
|
// 超时15秒打印信息
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.cbArr.forEach(cb => {
|
||||||
|
cb && cb("")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log('tcp connect error', err)
|
console.log('tcp connect error', err)
|
||||||
})
|
})
|
||||||
@ -34,42 +57,19 @@ class NewTcp {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.tcp.send({ data: data }, (err) => {
|
this.tcp.send({ data: data }, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
console.log("zj tcp end error", JSON.stringify(err))
|
||||||
|
console.log("zj tcp end error", data)
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
// console.log("zj tcp end success")
|
// console.log("zj tcp end success")
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onMessage(callback) {
|
public onMessage(callback) {
|
||||||
this.tcp.on("message", (value) => {
|
this.cbArr.push(callback)
|
||||||
if (value) {
|
|
||||||
let dataView = new DataView(value.message)
|
|
||||||
let str = ""
|
|
||||||
for (let i = 0; i < dataView?.byteLength; ++i) {
|
|
||||||
let c = String.fromCharCode(dataView?.getUint8(i))
|
|
||||||
if (c !== "\n") {
|
|
||||||
str += c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let strachArr = str.split(',')
|
|
||||||
if (strachArr[0] != '#DN_GD') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// console.log(`udp222 on message array buffer:${str}`);
|
|
||||||
|
|
||||||
strachArr[28] = globalThis.chuankoMsg || '0'
|
|
||||||
const newArr = JSON.parse(JSON.stringify(strachArr))
|
|
||||||
callback && callback(newArr.toString())
|
|
||||||
|
|
||||||
} else {
|
|
||||||
callback && callback('')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重连
|
// 重连
|
||||||
@ -93,6 +93,42 @@ class NewTcp {
|
|||||||
|
|
||||||
export const NewTcpClient = new NewTcp()
|
export const NewTcpClient = new NewTcp()
|
||||||
|
|
||||||
|
export const HandleCenterCode = (msgXml, isNewCenter) => {
|
||||||
|
//新监管
|
||||||
|
if (isNewCenter) {
|
||||||
|
const msg = JSON.parse(msgXml);
|
||||||
|
const result = msg?.data[0]?.result;
|
||||||
|
if (result) {
|
||||||
|
const {code,message,retval} = result
|
||||||
|
if (code != '1') {
|
||||||
|
const rMessage = decodeURIComponent(message as string)
|
||||||
|
Prompt.showToast({
|
||||||
|
message: rMessage,
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
return { code, message }
|
||||||
|
} else {
|
||||||
|
return { code, keystr: retval }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//正则匹配code message字段
|
||||||
|
const [code, message, keystr] = [/<code>(.*)<\/code>/i, /<message>(.*)<\/message>/i, /<keystr>(.*)<\/keystr>/i].map(pattern => {
|
||||||
|
const patternArr = pattern.exec(msgXml);
|
||||||
|
return patternArr && patternArr[1]
|
||||||
|
});
|
||||||
|
|
||||||
|
if (code != '1') {
|
||||||
|
Prompt.showToast({
|
||||||
|
message: decodeURIComponent(message as string),
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
return { code, message: decodeURIComponent(message) }
|
||||||
|
} else {
|
||||||
|
return { code, keystr, message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const XmlToJson = (result) => {
|
export const XmlToJson = (result) => {
|
||||||
let xmlOptions = {
|
let xmlOptions = {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import systemTime from '@ohos.systemDateTime';
|
import systemTime from '@ohos.systemDateTime';
|
||||||
import { expect } from '@ohos/hypium';
|
|
||||||
import FileUtil from './File';
|
import FileUtil from './File';
|
||||||
|
|
||||||
export function isSevenDaysAgo(date, days = 2) {
|
export function isSevenDaysAgo(date, days = 2) {
|
||||||
const today = new Date(); // 当前日期
|
const today = new Date(); // 当前日期
|
||||||
const target = new Date(date); // 需要判断的日期
|
const target = new Date(date); // 需要判断的日期
|
||||||
@ -14,6 +14,7 @@ export function isSevenDaysAgo(date,days=2) {
|
|||||||
console.log('diffDays', diffDays, days)
|
console.log('diffDays', diffDays, days)
|
||||||
return diffDays >= (Number(days));
|
return diffDays >= (Number(days));
|
||||||
}
|
}
|
||||||
|
|
||||||
// export async function writeLog(path,param){
|
// export async function writeLog(path,param){
|
||||||
// return
|
// return
|
||||||
// const fileUtil = new FileUtil(globalThis.context)
|
// const fileUtil = new FileUtil(globalThis.context)
|
||||||
@ -146,7 +147,6 @@ export function formatTime(time:number):string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 根据指定个数分割数组
|
// 根据指定个数分割数组
|
||||||
export function chunkArr(arr, size: number) {
|
export function chunkArr(arr, size: number) {
|
||||||
//判断如果不是数组(就没有length),或者size没有传值,size小于1,就返回空数组
|
//判断如果不是数组(就没有length),或者size没有传值,size小于1,就返回空数组
|
||||||
@ -227,8 +227,7 @@ export function string2Bytes(number, len){
|
|||||||
export function Array2Byte(array) {
|
export function Array2Byte(array) {
|
||||||
var buf = new ArrayBuffer(array.length);
|
var buf = new ArrayBuffer(array.length);
|
||||||
var view = new Uint8Array(buf);
|
var view = new Uint8Array(buf);
|
||||||
for (var i = 0; i != array.length; ++i)
|
for (var i = 0; i != array.length; ++i) {
|
||||||
{
|
|
||||||
view[i] = array[i] & 0xFF;
|
view[i] = array[i] & 0xFF;
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
@ -252,4 +251,32 @@ export function debounce(fn, delay){
|
|||||||
}
|
}
|
||||||
timer = setTimeout(fn, delay);
|
timer = setTimeout(fn, delay);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
// 循环打印一个字符串
|
||||||
|
/**
|
||||||
|
* 分段打印字符串
|
||||||
|
* @param {string} value - 需要打印的字符串
|
||||||
|
* @param {number} length - 每段的长度
|
||||||
|
*/
|
||||||
|
export function PrintStr(value, length) {
|
||||||
|
// 参数校验
|
||||||
|
if (typeof value !== 'string' || typeof length !== 'number' || length <= 0) {
|
||||||
|
console.error('参数无效:value 必须是字符串,length 必须是正整数');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果字符串长度小于等于分段长度,直接打印整个字符串
|
||||||
|
if (value.length <= length) {
|
||||||
|
console.log(value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分段打印
|
||||||
|
for (let i = 0; i < value.length; i += length) {
|
||||||
|
// 截取当前段
|
||||||
|
const segment = value.slice(i, i + length);
|
||||||
|
console.log("zj PrintStr", segment);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,3 +2,10 @@ export type SignalDataType = {
|
|||||||
key: string;
|
key: string;
|
||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export interface Response {
|
||||||
|
serialNumber: string
|
||||||
|
data: string
|
||||||
|
isForwordHttp: string
|
||||||
|
}
|
||||||
@ -1,5 +1,8 @@
|
|||||||
import TopLogo from './compontents/TopLogo';
|
import TopLogo from './compontents/TopLogo'
|
||||||
import prompt from '@ohos.prompt';
|
import ethernet from '@ohos.net.ethernet';
|
||||||
|
import prompt from '@ohos.prompt'
|
||||||
|
import { upDateTableByArray } from '../common/service/initable'
|
||||||
|
import { getSyncData } from '../common/service/initable'
|
||||||
import FileUtil from '../common/utils/File';
|
import FileUtil from '../common/utils/File';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
import { GlobalConfig } from '../config';
|
import { GlobalConfig } from '../config';
|
||||||
@ -100,7 +103,6 @@ struct Index {
|
|||||||
}
|
}
|
||||||
fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param), '')
|
fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param), '')
|
||||||
// upDateTableByArray('IpConfigTable',[])
|
// upDateTableByArray('IpConfigTable',[])
|
||||||
// @ts-ignore
|
|
||||||
ethernet.setIfaceConfig("eth0", {
|
ethernet.setIfaceConfig("eth0", {
|
||||||
mode: 0,
|
mode: 0,
|
||||||
ipAddr: this.inputTextList1[9],
|
ipAddr: this.inputTextList1[9],
|
||||||
@ -170,7 +172,7 @@ struct Index {
|
|||||||
this.inputTextList1[3] = result.centerPort
|
this.inputTextList1[3] = result.centerPort
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ts-ignore
|
|
||||||
ethernet.getIfaceConfig("eth0", (error, value) => {
|
ethernet.getIfaceConfig("eth0", (error, value) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
// that.errorMsg='error'
|
// that.errorMsg='error'
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import errorMsgDialog from './compontents/errorMsgDialog';
|
|||||||
import imageBtn from './compontents/imageBtn';
|
import imageBtn from './compontents/imageBtn';
|
||||||
import FileUtil from '../common/utils/File';
|
import FileUtil from '../common/utils/File';
|
||||||
import DB, { ColumnType } from '../common/database/DbSql';
|
import DB, { ColumnType } from '../common/database/DbSql';
|
||||||
|
import { NewTcpClient } from '../common/utils/new/tcp';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@ -167,8 +168,6 @@ struct UserInfo {
|
|||||||
)
|
)
|
||||||
private filePhoto: FilePhoto
|
private filePhoto: FilePhoto
|
||||||
private avPlayer
|
private avPlayer
|
||||||
private AccountTable = new AccountTable(() => {
|
|
||||||
}, USER);
|
|
||||||
private context = getContext(this) as common.UIAbilityContext;
|
private context = getContext(this) as common.UIAbilityContext;
|
||||||
private labelBlocks = [
|
private labelBlocks = [
|
||||||
{ label: '考生姓名', key: 'xm' },
|
{ label: '考生姓名', key: 'xm' },
|
||||||
@ -919,7 +918,12 @@ struct UserInfo {
|
|||||||
resolve(true)
|
resolve(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let plcValue = globalThis.udpClient.getCurrentMessage();
|
// let plcValue = ""
|
||||||
|
let plcValue = globalThis.udpClient.getCurrentMessage;
|
||||||
|
// NewTcpClient.onMessage((value) => {
|
||||||
|
// console.log(value)
|
||||||
|
// plcValue = value
|
||||||
|
// })
|
||||||
const msgArr = plcValue.split(',') || ''
|
const msgArr = plcValue.split(',') || ''
|
||||||
const mkg = msgArr[14];
|
const mkg = msgArr[14];
|
||||||
const fdjzs = msgArr[25];
|
const fdjzs = msgArr[25];
|
||||||
|
|||||||
@ -346,21 +346,25 @@ export default struct SignDisplayCom {
|
|||||||
// getSignal(msg)
|
// getSignal(msg)
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
// NewTcpClient.onMessage((msg) => {
|
||||||
|
// console.log("zj msg", msg)
|
||||||
|
// getSignal(msg)
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
// clearInterval(globalThis.signalTimer)
|
||||||
|
// globalThis.signalTimer = setInterval(() => {
|
||||||
|
// const msgStr = globalThis.msgStr
|
||||||
|
// if (msgStr) {
|
||||||
|
// getSignal(msgStr)
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }, 200)
|
||||||
NewTcpClient.onMessage((msg) => {
|
NewTcpClient.onMessage((msg) => {
|
||||||
console.log("zj msg", msg)
|
console.log("zj msg", msg)
|
||||||
getSignal(msg)
|
getSignal(msg)
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
clearInterval(globalThis.signalTimer)
|
|
||||||
globalThis.signalTimer = setInterval(() => {
|
|
||||||
const msgStr = globalThis.msgStr
|
|
||||||
if (msgStr) {
|
|
||||||
getSignal(msgStr)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 200)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPageShow() {
|
onPageShow() {
|
||||||
console.info('SURENJUN', 123)
|
console.info('SURENJUN', 123)
|
||||||
|
|||||||
Binary file not shown.
@ -239,7 +239,9 @@ export default class Judge {
|
|||||||
if (stachArr[0] != '#DN_GD' || isUdpEnd) {
|
if (stachArr[0] != '#DN_GD' || isUdpEnd) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const plcData = await getPlcData(msg);
|
console.log("zj getPlcData start")
|
||||||
|
const plcData = await this.getPlcData(msg);
|
||||||
|
console.log("zj getPlcData end")
|
||||||
// 4.过程数据
|
// 4.过程数据
|
||||||
await fileLog.setExamJudgeData(plcData)
|
await fileLog.setExamJudgeData(plcData)
|
||||||
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
//检测到有无锡所设备接入,需要发送特定的数据,供检测
|
||||||
@ -257,6 +259,7 @@ export default class Judge {
|
|||||||
if (!isExamEnd) {
|
if (!isExamEnd) {
|
||||||
await examJudgeRealExam(plcData)
|
await examJudgeRealExam(plcData)
|
||||||
}
|
}
|
||||||
|
console.log("zj plcData", plcData.toString())
|
||||||
const udpIndex = globalThis.udpIndex;
|
const udpIndex = globalThis.udpIndex;
|
||||||
let [prevJd, preWd] = [0, 0]
|
let [prevJd, preWd] = [0, 0]
|
||||||
if (udpIndex % 5 === 0 && !isUdpEnd) {
|
if (udpIndex % 5 === 0 && !isUdpEnd) {
|
||||||
@ -1830,7 +1833,8 @@ export default class Judge {
|
|||||||
// });
|
// });
|
||||||
NewTcpClient.onMessage((msg) => {
|
NewTcpClient.onMessage((msg) => {
|
||||||
console.info('socketTag[PLC.UdpClient]', '收到udp回调数据')
|
console.info('socketTag[PLC.UdpClient]', '收到udp回调数据')
|
||||||
handleUdp(msg)
|
console.log("zj msg1", msg)
|
||||||
|
this.handleUdp(msg)
|
||||||
const udpIndex = globalThis.udpIndex;
|
const udpIndex = globalThis.udpIndex;
|
||||||
if (udpIndex % 5 === 0) {
|
if (udpIndex % 5 === 0) {
|
||||||
handDistance();
|
handDistance();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user