fix: 济南后置机方案

This commit is contained in:
wangzhongjie 2025-02-21 15:38:00 +08:00
parent 912f5636db
commit 0d6b3c7c07
2 changed files with 27 additions and 32 deletions

View File

@ -1,8 +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';
let baseHost = globalThis.host;
import FileUtil from '../common/utils/File'; import FileUtil from '../common/utils/File';
import FileLog from '../pages/judgeSDK/utils/fileLog';
let baseHost = globalThis.host;
//监管接口序列号映射 //监管接口序列号映射
const gjxlhObj = { const gjxlhObj = {
@ -14,28 +14,34 @@ const gjxlhObj = {
'17C56': '02-21-000014', '17C56': '02-21-000014',
} }
interface WR{ interface WR {
message?:string message?: string
code:number code: number
} }
export default async function writeObjectOutNew(data,filePath): Promise<WR> { export default async function writeObjectOutNew(data, filePath): Promise<WR> {
const fileUtil = new FileUtil(globalThis.context); const fileUtil = new FileUtil(globalThis.context);
const {jkid , drvexam} = data; const {jkid , drvexam} = data;
const basic = await getBasicConfig(jkid); const basic = await getBasicConfig(jkid);
const params = await getParams(jkid, drvexam); const params = await getParams(jkid, drvexam);
const {wglb,jkxlh,glbm,jgbh,sjbs} = basic; const {wglb,jkxlh,glbm,jgbh,sjbs} = basic;
if(filePath){ if (filePath) {
await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({ await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify({
wglb,jkxlh,glbm,jgbh,sjbs, wglb,
data:params.data, jkxlh,
file:{...params.file,param:[]}, glbm,
jgbh,
sjbs,
data: params.data,
file: {
...params.file, param: []
},
})); }));
} }
// let connectTimeout = sjbs === '02-21-000014' ?60000:1 // let connectTimeout = sjbs === '02-21-000014' ?60000:1
console.info('surenjun','调用新监管') console.info('surenjun', '调用新监管')
let temp let temp
try { try {
temp = await request({ temp = await request({
@ -69,8 +75,8 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> {
temp = e temp = e
} }
console.log("temp message: ", JSON.stringify(temp)) console.log("temp message: ", JSON.stringify(temp))
if(filePath){ if (filePath) {
await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify(temp) +`\n`); await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(temp) + `\n`);
} }
return temp return temp

View File

@ -13,13 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
// @ts-ignore
import socket, { UDPSocket } from '@ohos.net.socket'; import socket, { UDPSocket } from '@ohos.net.socket';
import { Array2Byte, dateFormat, fillZero, string2Bytes } from '../utils/tools'; import { Array2Byte, dateFormat, fillZero, string2Bytes } from '../utils/tools';
import FileUtil from '../../common/utils/File'; import FileUtil from '../../common/utils/File';
import prompt from '@ohos.prompt'; import prompt from '@ohos.prompt';
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
import { getUDP } from './GlobalUdp'; import { getUDP } from './GlobalUdp';
import UdpByOne from './UdpByOne';
const TAG = '[UdpDemo.UdpClient]' const TAG = '[UdpDemo.UdpClient]'
@ -47,7 +47,6 @@ export default class UdpClientByCenter {
private isWorking: Boolean = false private isWorking: Boolean = false
private plcUdpError = false; private plcUdpError = false;
private initParam private initParam
private UPDOne: any
constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
this.localIp = udplocalIp this.localIp = udplocalIp
@ -58,7 +57,6 @@ export default class UdpClientByCenter {
} }
this.udp = socket.constructUDPSocketInstance(); this.udp = socket.constructUDPSocketInstance();
this.initPath() this.initPath()
this.UPDOne = new UdpByOne()
} }
getStatus() { getStatus() {
@ -146,14 +144,14 @@ export default class UdpClientByCenter {
//length消息体bufferlength id消息类型id bodyStr消息体string //length消息体bufferlength id消息类型id bodyStr消息体string
// setMsyBody(id,bodyByte){ // setMsyBody(id,bodyByte){
setMsgHead({ id, list, placeId=62, carNo=489 }) { setMsgHead({id, list, placeId=62, carNo=489}) {
let a = string2Bytes(`${id}${fillZero(placeId, 3)}`, 2 * 8); let a = string2Bytes(`${id}${fillZero(placeId, 3)}`, 2 * 8);
let b = string2Bytes(`${fillZero(carNo, 4)}${globalThis.lshNo}`, 4 * 8); let b = string2Bytes(`${fillZero(carNo, 4)}${globalThis.lshNo}`, 4 * 8);
let c = string2Bytes(list.length, 2 * 8); let c = string2Bytes(list.length, 2 * 8);
return [...a, ...b, ...c]; return [...a, ...b, ...c];
} }
setMsgBody({ id, list }) { setMsgBody({id,list}) {
let tmpList = [] let tmpList = []
tmpList = list tmpList = list
@ -257,16 +255,10 @@ export default class UdpClientByCenter {
list.push(arr[i]) list.push(arr[i])
} }
this.stashFn({ this.stashFn({
id, id, length, body: list, sendId: this.sendId
length,
body: list,
sendId: this.sendId
}) })
callback({ callback({
id, id, length, body: list, sendId: this.sendId
length,
body: list,
sendId: this.sendId
}) })
@ -298,15 +290,12 @@ export default class UdpClientByCenter {
}) })
} }
// TODO 赋值onMessage_1
//plc //plc
onMessage_1(callback?) { onMessage_1(callback?) {
this.onMessage_1Callback = callback; this.onMessage_1Callback = callback;
this.UPDOne.receiveMsg(callback); this.udp && this.udp.on('message', this.message_1Fn);
// this.udp && this.udp.on('message', this.message_1Fn);
} }
closeMessage_1() { closeMessage_1() {
console.info('surenjun', 'getUDP关闭udp message监听事件') console.info('surenjun', 'getUDP关闭udp message监听事件')
this.udp.off('message', this.message_1Fn); this.udp.off('message', this.message_1Fn);