fix: 济南后置机方案
This commit is contained in:
		
							parent
							
								
									912f5636db
								
							
						
					
					
						commit
						0d6b3c7c07
					
				| @ -1,8 +1,8 @@ | ||||
| import { getSyncData } from '../common/service/initable'; | ||||
| import request from "../common/utils/request" | ||||
| let baseHost = globalThis.host; | ||||
| import request from '../common/utils/request'; | ||||
| import FileUtil from '../common/utils/File'; | ||||
| import FileLog from '../pages/judgeSDK/utils/fileLog'; | ||||
| 
 | ||||
| let baseHost = globalThis.host; | ||||
| 
 | ||||
| //监管接口序列号映射
 | ||||
| const gjxlhObj = { | ||||
| @ -14,28 +14,34 @@ const gjxlhObj = { | ||||
|   '17C56': '02-21-000014', | ||||
| } | ||||
| 
 | ||||
| interface WR{ | ||||
|   message?:string | ||||
|   code:number | ||||
| interface WR { | ||||
|   message?: string | ||||
|   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 {jkid , drvexam} = data; | ||||
|   const basic = await getBasicConfig(jkid); | ||||
|   const params = await getParams(jkid, drvexam); | ||||
|   const {wglb,jkxlh,glbm,jgbh,sjbs} = basic; | ||||
| 
 | ||||
|   if(filePath){ | ||||
|     await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify({ | ||||
|       wglb,jkxlh,glbm,jgbh,sjbs, | ||||
|       data:params.data, | ||||
|       file:{...params.file,param:[]}, | ||||
|   if (filePath) { | ||||
|     await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify({ | ||||
|       wglb, | ||||
|       jkxlh, | ||||
|       glbm, | ||||
|       jgbh, | ||||
|       sjbs, | ||||
|       data: params.data, | ||||
|       file: { | ||||
|         ...params.file, param: [] | ||||
|       }, | ||||
|     })); | ||||
|   } | ||||
| 
 | ||||
|   // let connectTimeout = sjbs === '02-21-000014' ?60000:1
 | ||||
|   console.info('surenjun','调用新监管') | ||||
|   console.info('surenjun', '调用新监管') | ||||
|   let temp | ||||
|   try { | ||||
|     temp = await request({ | ||||
| @ -69,8 +75,8 @@ export default async function writeObjectOutNew(data,filePath): Promise<WR> { | ||||
|     temp = e | ||||
|   } | ||||
|   console.log("temp message: ", JSON.stringify(temp)) | ||||
|   if(filePath){ | ||||
|    await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`,JSON.stringify(temp) +`\n`); | ||||
|   if (filePath) { | ||||
|     await fileUtil.editFile(`${filePath}/wuxi_exam_data.txt`, JSON.stringify(temp) + `\n`); | ||||
|   } | ||||
|   return temp | ||||
| 
 | ||||
|  | ||||
| @ -13,13 +13,13 @@ | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| // @ts-ignore
 | ||||
| import socket, { UDPSocket } from '@ohos.net.socket'; | ||||
| import { Array2Byte, dateFormat, fillZero, string2Bytes } from '../utils/tools'; | ||||
| import FileUtil from '../../common/utils/File'; | ||||
| import prompt from '@ohos.prompt'; | ||||
| import promptAction from '@ohos.promptAction'; | ||||
| import { getUDP } from './GlobalUdp'; | ||||
| import UdpByOne from './UdpByOne'; | ||||
| 
 | ||||
| const TAG = '[UdpDemo.UdpClient]' | ||||
| 
 | ||||
| @ -47,7 +47,6 @@ export default class UdpClientByCenter { | ||||
|   private isWorking: Boolean = false | ||||
|   private plcUdpError = false; | ||||
|   private initParam | ||||
|   private UPDOne: any | ||||
| 
 | ||||
|   constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { | ||||
|     this.localIp = udplocalIp | ||||
| @ -58,7 +57,6 @@ export default class UdpClientByCenter { | ||||
|     } | ||||
|     this.udp = socket.constructUDPSocketInstance(); | ||||
|     this.initPath() | ||||
|     this.UPDOne = new UdpByOne() | ||||
|   } | ||||
| 
 | ||||
|   getStatus() { | ||||
| @ -146,14 +144,14 @@ export default class UdpClientByCenter { | ||||
|   //length消息体bufferlength   id消息类型id  bodyStr消息体string
 | ||||
|   // 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 b = string2Bytes(`${fillZero(carNo, 4)}${globalThis.lshNo}`, 4 * 8); | ||||
|     let c = string2Bytes(list.length, 2 * 8); | ||||
|     return [...a, ...b, ...c]; | ||||
|   } | ||||
| 
 | ||||
|   setMsgBody({ id, list }) { | ||||
|   setMsgBody({id,list}) { | ||||
|     let tmpList = [] | ||||
|     tmpList = list | ||||
| 
 | ||||
| @ -257,16 +255,10 @@ export default class UdpClientByCenter { | ||||
|         list.push(arr[i]) | ||||
|       } | ||||
|       this.stashFn({ | ||||
|         id, | ||||
|         length, | ||||
|         body: list, | ||||
|         sendId: this.sendId | ||||
|         id, length, body: list, sendId: this.sendId | ||||
|       }) | ||||
|       callback({ | ||||
|         id, | ||||
|         length, | ||||
|         body: list, | ||||
|         sendId: this.sendId | ||||
|         id, length, body: list, sendId: this.sendId | ||||
|       }) | ||||
| 
 | ||||
| 
 | ||||
| @ -298,15 +290,12 @@ export default class UdpClientByCenter { | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|   // TODO 赋值onMessage_1
 | ||||
|   //plc
 | ||||
|   onMessage_1(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() { | ||||
|     console.info('surenjun', 'getUDP关闭udp message监听事件') | ||||
|     this.udp.off('message', this.message_1Fn); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user