流程
查验结果
This commit is contained in:
		
							parent
							
								
									8a4a73f19e
								
							
						
					
					
						commit
						f2e13a9f35
					
				
							
								
								
									
										2
									
								
								entry/src/main/ets/api/typings.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								entry/src/main/ets/api/typings.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -762,6 +762,8 @@ declare namespace API { | ||||
|     name?: string; | ||||
|     params?: Record<string, any>; | ||||
|     remark?: string; | ||||
|     robotId?: string; | ||||
|     robotIp?: string | ||||
|     stationId?: number; | ||||
|     status?: string; | ||||
|     updateBy?: string; | ||||
|  | ||||
| @ -6,6 +6,8 @@ import { RebootControl } from './utils/Control' | ||||
| import { promptAction, router } from '@kit.ArkUI' | ||||
| import { CommandCode, commandService } from '../../utils/CommandService' | ||||
| import Logger from '../../utils/Logger' | ||||
| import { getPadRecordInfoUsingGet } from '../../api/padController' | ||||
| import { getDeviceId } from '../../utils/System' | ||||
| 
 | ||||
| function TouchEventWrapper(callback: Function) { | ||||
|   let tick: number = -1 | ||||
| @ -31,7 +33,7 @@ function TouchEventWrapper(callback: Function) { | ||||
| @Entry | ||||
| struct Control { | ||||
|   @State select: number = 0 | ||||
|   @State line: API.VcInspectionLine[] = AppStorage.get("line") || [] | ||||
|   @State line: API.VcInspectionLine[] = [] | ||||
|   @State mode: number[] = [] | ||||
|   private control: RebootControl = new RebootControl("ws://192.168.7.101:10000") | ||||
|   private forward: (event: TouchEvent) => void = TouchEventWrapper(() => { | ||||
| @ -48,11 +50,20 @@ struct Control { | ||||
|   }) | ||||
| 
 | ||||
|   async aboutToAppear(): Promise<void> { | ||||
|     await this.control.init() | ||||
|     this.mode = this.line.map(() => 0) | ||||
|     this.control.getMode().then(res => { | ||||
|       Logger.info(res) | ||||
|       this.mode[this.select] = res.mode | ||||
|     this.getPadInfo() | ||||
|   } | ||||
| 
 | ||||
|   async getPadInfo() { | ||||
|     let deviceId = await getDeviceId() | ||||
|     getPadRecordInfoUsingGet({ imei: deviceId }).then(async (res) => { | ||||
|       this.line = res.data?.lines || [] | ||||
|       this.control = new RebootControl(`ws://${this.line[this.select]?.robotIp}:10000`) | ||||
|       await this.control.init() | ||||
|       this.mode = this.line.map(() => 0) | ||||
|       this.control.getMode().then(res => { | ||||
|         Logger.info(res) | ||||
|         this.mode[this.select] = res.mode | ||||
|       }) | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| @ -123,11 +134,13 @@ struct Control { | ||||
|                   ForEach(this.line, (menu: API.VcInspectionLine, index: number) => { | ||||
|                     CusMenuItem({ text: menu.name, active: this.select === index }) | ||||
|                       .margin({ bottom: 24 }) | ||||
|                       .onClick(() => { | ||||
|                       .onClick(async () => { | ||||
|                         if (this.mode[this.select] === 1) { | ||||
|                           this.control.setMode(0) | ||||
|                         } | ||||
|                         this.select = index | ||||
|                         this.control = new RebootControl(`ws://${this.line[this.select]?.robotIp}:10000`) | ||||
|                         await this.control.init() | ||||
|                       }) | ||||
|                   }) | ||||
|                 }.width("100%").padding({ left: 24, right: 24 }) | ||||
|  | ||||
| @ -3,6 +3,7 @@ import { TaskPool } from '../../../utils/TaskPool' | ||||
| import { EventType, WebsocketClient } from '../../../utils/WebsocketUtils' | ||||
| import { VehicleBean, VehicleInfo } from './Model' | ||||
| import { BusinessError } from '@kit.BasicServicesKit' | ||||
| import { promptAction } from '@kit.ArkUI' | ||||
| 
 | ||||
| const Tag = "RebootControl" | ||||
| 
 | ||||
| @ -58,7 +59,14 @@ export class RebootControl { | ||||
|   } | ||||
| 
 | ||||
|   setMode(mode: number) { | ||||
|     return this.service.send(JSON.stringify({ mode })) | ||||
|     return new Promise<boolean>((resolve, reject) => { | ||||
|       this.service.send(JSON.stringify({ mode })).then(resolve).catch((err: BusinessError) => { | ||||
|         promptAction.showToast({ | ||||
|           message: JSON.stringify(err) | ||||
|         }) | ||||
|         reject(err) | ||||
|       }) | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|   destroy() { | ||||
|  | ||||
| @ -4,20 +4,49 @@ import { Title } from '../components/title/Index' | ||||
| import { promptAction, router } from '@kit.ArkUI' | ||||
| import { getStepListUsingGet } from '../../api/padController' | ||||
| import { CusMenuItem } from './components/MenuItem' | ||||
| import { CommandCode, commandService } from '../../utils/CommandService' | ||||
| import { | ||||
|   CommandCode, | ||||
|   commandService, | ||||
|   CommandType, | ||||
|   Message, | ||||
|   PostCurrentStepMessage, | ||||
| } from '../../utils/CommandService' | ||||
| import Logger from '../../utils/Logger' | ||||
| 
 | ||||
| interface RouterParams { | ||||
|   lineId: number | ||||
| } | ||||
| 
 | ||||
| const Tag = "[Process]" | ||||
| 
 | ||||
| @Component | ||||
| @Entry | ||||
| struct Process { | ||||
|   @State process: API.StepVo[] = [] | ||||
|   @State select: number = -1 | ||||
|   @State currentStep: number = 6 | ||||
|   // @State currentStep: number = 0 | ||||
|   private lineId: number = -1 | ||||
|   private onProcess = (msg: Message<PostCurrentStepMessage>) => { | ||||
|     if (msg.type === CommandType.PostCurrentStep) { | ||||
|       Logger.info(Tag, msg) | ||||
|       if (Number(msg.body.lineId) === this.lineId) { | ||||
|         let current = 0 | ||||
|         for (let i = 0; i < this.process.length; i++) { | ||||
|           if (this.process[i].code === msg.body.stepCode) { | ||||
|             this.process[i].status === "2" | ||||
|             current = i | ||||
|           } else if (i < current) { | ||||
|             this.process[i].status === "1" | ||||
|           } else { | ||||
|             this.process[i].status === "0" | ||||
|           } | ||||
|         } | ||||
|         getStepListUsingGet({ lineId: this.lineId }).then(res => { | ||||
|           this.process = res.data || [] | ||||
|         }) | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   aboutToAppear(): void { | ||||
|     const params = router.getParams() as RouterParams; | ||||
| @ -25,32 +54,11 @@ struct Process { | ||||
|     getStepListUsingGet({ lineId: this.lineId }).then(res => { | ||||
|       this.process = res.data || [] | ||||
|     }) | ||||
|     // getStageAndStepInfoUsingGet().then(res => { | ||||
|     //   let len = 0 | ||||
|     //   this.process = (res.data || []).map((item) => { | ||||
|     //     let result: API.StageAndStepRsp = { | ||||
|     //       stageCode: item.stageCode, | ||||
|     //       stageId: item.stageId, | ||||
|     //       stageName: item.stageName, | ||||
|     //       stepList: item.stepList?.map((sub, index) => { | ||||
|     //         return { | ||||
|     //           code: sub.code, | ||||
|     //           id: sub.id, | ||||
|     //           name: sub.name, | ||||
|     //           orderNo: sub.orderNo, | ||||
|     //           stageId: sub.stageId, | ||||
|     //           index: len + index + 1 | ||||
|     //         } as API.StepVo | ||||
|     //       }), | ||||
|     //       count: len | ||||
|     //     } | ||||
|     //     len += item.stepList?.length || 0 | ||||
|     //     return result | ||||
|     //   }) | ||||
|     //   if (this.process.length > 0) { | ||||
|     //     this.select = this.process[0].stepList?.[0]?.id || -1 | ||||
|     //   } | ||||
|     // }) | ||||
|     commandService.subscribe(this.onProcess) | ||||
|   } | ||||
| 
 | ||||
|   aboutToDisappear(): void { | ||||
|     commandService.unsubscribe(this.onProcess) | ||||
|   } | ||||
| 
 | ||||
|   build() { | ||||
| @ -84,9 +92,6 @@ struct Process { | ||||
|                     CusMenuItem({ | ||||
|                       step: step, | ||||
|                       index: index + 1, | ||||
|                       // onSelect: (id) => { | ||||
|                       //   this.select = id | ||||
|                       // } | ||||
|                     }) | ||||
|                   }) | ||||
|                 }.width("100%").padding({ left: 24, right: 24 }) | ||||
|  | ||||
| @ -192,14 +192,14 @@ struct Detail { | ||||
|                     Text("左前45度照片").label() | ||||
|                   }.margin({ right: 6 }).layoutWeight(1).height("100%") | ||||
| 
 | ||||
|                   Stack({ alignContent: Alignment.TopStart }) { | ||||
|                     Image(this.rightBackward) | ||||
|                       .alt($rawfile("images/vehicle/default.png")) | ||||
|                       .width("100%") | ||||
|                       .height("100%") | ||||
|                       .objectFit(ImageFit.Fill) | ||||
|                     Text("右后45度照片").label() | ||||
|                   }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||
|                   // Stack({ alignContent: Alignment.TopStart }) { | ||||
|                   //   Image(this.rightBackward) | ||||
|                   //     .alt($rawfile("images/vehicle/default.png")) | ||||
|                   //     .width("100%") | ||||
|                   //     .height("100%") | ||||
|                   //     .objectFit(ImageFit.Fill) | ||||
|                   //   Text("右后45度照片").label() | ||||
|                   // }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||
|                 }.margin({ right: 6 }).layoutWeight(1) | ||||
| 
 | ||||
|                 Row() { | ||||
| @ -223,6 +223,81 @@ struct Detail { | ||||
|                     Text("左前45度视频").label() | ||||
|                   }.margin({ right: 6 }).layoutWeight(1).height("100%") | ||||
| 
 | ||||
|                   // Stack({ alignContent: Alignment.TopStart }) { | ||||
|                   //   if (this.rightBackward) { | ||||
|                   //     VideoPlayer({ | ||||
|                   //       isFullScreen: this.isFullScreen, | ||||
|                   //       showPreview: true, | ||||
|                   //       attribute: { | ||||
|                   //         preview: $rawfile("images/vehicle/default.png"), | ||||
|                   //         type: "network" | ||||
|                   //       }, | ||||
|                   //       url: this.rightBackward | ||||
|                   //     }) | ||||
|                   //   } else { | ||||
|                   //     Image($rawfile("images/vehicle/default.png")) | ||||
|                   //       .width("100%") | ||||
|                   //       .height("100%") | ||||
|                   //       .objectFit(ImageFit.Fill) | ||||
|                   //   } | ||||
|                   //   Text("右后45度视频").label() | ||||
|                   // }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||
|                 }.margin({ right: 6 }).layoutWeight(1) | ||||
|               } | ||||
|               .width("100%") | ||||
|               .padding({ left: 6, top: 12, bottom: 12 }) | ||||
|               .height(240) | ||||
|               .margin({ bottom: 18 }) | ||||
|               .backgroundColor(0xE7F3FF) | ||||
| 
 | ||||
|               Row() { | ||||
|                 Column() { | ||||
|                   Label({ mode: 2, label: "号牌号码", value: this.data.licensePlateNumber }) | ||||
|                   Label({ mode: 2, label: "车辆品牌", value: this.data.vehicleBrandName }) | ||||
|                   Label({ mode: 2, label: "车身颜色", value: this.data.vehicleColor }) | ||||
|                 }.margin({ right: 6 }).layoutWeight(1).justifyContent(FlexAlign.SpaceBetween).height("100%") | ||||
| 
 | ||||
|                 Row() { | ||||
|                   // Stack({ alignContent: Alignment.TopStart }) { | ||||
|                   //   Image(this.leftForward) | ||||
|                   //     .alt($rawfile("images/vehicle/default.png")) | ||||
|                   //     .width("100%") | ||||
|                   //     .height("100%") | ||||
|                   //     .objectFit(ImageFit.Fill) | ||||
|                   //   Text("左前45度照片").label() | ||||
|                   // }.margin({ right: 6 }).layoutWeight(1).height("100%") | ||||
| 
 | ||||
|                   Stack({ alignContent: Alignment.TopStart }) { | ||||
|                     Image(this.rightBackward) | ||||
|                       .alt($rawfile("images/vehicle/default.png")) | ||||
|                       .width("100%") | ||||
|                       .height("100%") | ||||
|                       .objectFit(ImageFit.Fill) | ||||
|                     Text("右后45度照片").label() | ||||
|                   }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||
|                 }.margin({ right: 6 }).layoutWeight(1) | ||||
| 
 | ||||
|                 Row() { | ||||
|                   // Stack({ alignContent: Alignment.TopStart }) { | ||||
|                   //   if (this.leftForward) { | ||||
|                   //     VideoPlayer({ | ||||
|                   //       isFullScreen: this.isFullScreen, | ||||
|                   //       showPreview: true, | ||||
|                   //       attribute: { | ||||
|                   //         preview: $rawfile("images/vehicle/default.png"), | ||||
|                   //         type: "network" | ||||
|                   //       }, | ||||
|                   //       url: this.leftForward | ||||
|                   //     }) | ||||
|                   //   } else { | ||||
|                   //     Image($rawfile("images/vehicle/default.png")) | ||||
|                   //       .width("100%") | ||||
|                   //       .height("100%") | ||||
|                   //       .objectFit(ImageFit.Fill) | ||||
|                   //   } | ||||
|                   //   Text("左前45度视频").label() | ||||
|                   // }.margin({ right: 6 }).layoutWeight(1).height("100%") | ||||
| 
 | ||||
|                   Stack({ alignContent: Alignment.TopStart }) { | ||||
|                     if (this.rightBackward) { | ||||
|                       VideoPlayer({ | ||||
| @ -243,7 +318,6 @@ struct Detail { | ||||
|                     Text("右后45度视频").label() | ||||
|                   }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||
|                 }.margin({ right: 6 }).layoutWeight(1) | ||||
| 
 | ||||
|               } | ||||
|               .width("100%") | ||||
|               .padding({ left: 6, top: 12, bottom: 12 }) | ||||
|  | ||||
| @ -5,7 +5,7 @@ import { util } from '@kit.ArkTS'; | ||||
| 
 | ||||
| const Tag = "CommandService" | ||||
| 
 | ||||
| interface Message<T = Object> { | ||||
| export interface Message<T = Object> { | ||||
|   type: CommandType | ||||
|   reqCode: string | ||||
|   body: T | ||||
| @ -22,15 +22,22 @@ interface CommandBody { | ||||
|   name: string | ||||
| } | ||||
| 
 | ||||
| interface ResponseMessage { | ||||
| export interface ResponseMessage { | ||||
|   code: string | ||||
|   msg: string | ||||
| } | ||||
| 
 | ||||
| enum CommandType { | ||||
| export interface PostCurrentStepMessage { | ||||
|   lineId: string | ||||
|   stepCode: string | ||||
|   stepName: string | ||||
| } | ||||
| 
 | ||||
| export enum CommandType { | ||||
|   HandleAlarm = "handleAlarm", | ||||
|   PostCmd = "postCmd", | ||||
|   PostCmdRsp = "postCmdRsp" | ||||
|   PostCmdRsp = "postCmdRsp", | ||||
|   PostCurrentStep = "postCurrentStep" | ||||
| } | ||||
| 
 | ||||
| export enum CommandCode { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user