流程
查验结果
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; |     name?: string; | ||||||
|     params?: Record<string, any>; |     params?: Record<string, any>; | ||||||
|     remark?: string; |     remark?: string; | ||||||
|  |     robotId?: string; | ||||||
|  |     robotIp?: string | ||||||
|     stationId?: number; |     stationId?: number; | ||||||
|     status?: string; |     status?: string; | ||||||
|     updateBy?: string; |     updateBy?: string; | ||||||
|  | |||||||
| @ -6,6 +6,8 @@ import { RebootControl } from './utils/Control' | |||||||
| import { promptAction, router } from '@kit.ArkUI' | import { promptAction, router } from '@kit.ArkUI' | ||||||
| import { CommandCode, commandService } from '../../utils/CommandService' | import { CommandCode, commandService } from '../../utils/CommandService' | ||||||
| import Logger from '../../utils/Logger' | import Logger from '../../utils/Logger' | ||||||
|  | import { getPadRecordInfoUsingGet } from '../../api/padController' | ||||||
|  | import { getDeviceId } from '../../utils/System' | ||||||
| 
 | 
 | ||||||
| function TouchEventWrapper(callback: Function) { | function TouchEventWrapper(callback: Function) { | ||||||
|   let tick: number = -1 |   let tick: number = -1 | ||||||
| @ -31,7 +33,7 @@ function TouchEventWrapper(callback: Function) { | |||||||
| @Entry | @Entry | ||||||
| struct Control { | struct Control { | ||||||
|   @State select: number = 0 |   @State select: number = 0 | ||||||
|   @State line: API.VcInspectionLine[] = AppStorage.get("line") || [] |   @State line: API.VcInspectionLine[] = [] | ||||||
|   @State mode: number[] = [] |   @State mode: number[] = [] | ||||||
|   private control: RebootControl = new RebootControl("ws://192.168.7.101:10000") |   private control: RebootControl = new RebootControl("ws://192.168.7.101:10000") | ||||||
|   private forward: (event: TouchEvent) => void = TouchEventWrapper(() => { |   private forward: (event: TouchEvent) => void = TouchEventWrapper(() => { | ||||||
| @ -48,12 +50,21 @@ struct Control { | |||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   async aboutToAppear(): Promise<void> { |   async aboutToAppear(): Promise<void> { | ||||||
|  |     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() |       await this.control.init() | ||||||
|       this.mode = this.line.map(() => 0) |       this.mode = this.line.map(() => 0) | ||||||
|       this.control.getMode().then(res => { |       this.control.getMode().then(res => { | ||||||
|         Logger.info(res) |         Logger.info(res) | ||||||
|         this.mode[this.select] = res.mode |         this.mode[this.select] = res.mode | ||||||
|       }) |       }) | ||||||
|  |     }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   aboutToDisappear(): void { |   aboutToDisappear(): void { | ||||||
| @ -123,11 +134,13 @@ struct Control { | |||||||
|                   ForEach(this.line, (menu: API.VcInspectionLine, index: number) => { |                   ForEach(this.line, (menu: API.VcInspectionLine, index: number) => { | ||||||
|                     CusMenuItem({ text: menu.name, active: this.select === index }) |                     CusMenuItem({ text: menu.name, active: this.select === index }) | ||||||
|                       .margin({ bottom: 24 }) |                       .margin({ bottom: 24 }) | ||||||
|                       .onClick(() => { |                       .onClick(async () => { | ||||||
|                         if (this.mode[this.select] === 1) { |                         if (this.mode[this.select] === 1) { | ||||||
|                           this.control.setMode(0) |                           this.control.setMode(0) | ||||||
|                         } |                         } | ||||||
|                         this.select = index |                         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 }) |                 }.width("100%").padding({ left: 24, right: 24 }) | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ import { TaskPool } from '../../../utils/TaskPool' | |||||||
| import { EventType, WebsocketClient } from '../../../utils/WebsocketUtils' | import { EventType, WebsocketClient } from '../../../utils/WebsocketUtils' | ||||||
| import { VehicleBean, VehicleInfo } from './Model' | import { VehicleBean, VehicleInfo } from './Model' | ||||||
| import { BusinessError } from '@kit.BasicServicesKit' | import { BusinessError } from '@kit.BasicServicesKit' | ||||||
|  | import { promptAction } from '@kit.ArkUI' | ||||||
| 
 | 
 | ||||||
| const Tag = "RebootControl" | const Tag = "RebootControl" | ||||||
| 
 | 
 | ||||||
| @ -58,7 +59,14 @@ export class RebootControl { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   setMode(mode: number) { |   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() { |   destroy() { | ||||||
|  | |||||||
| @ -4,20 +4,49 @@ import { Title } from '../components/title/Index' | |||||||
| import { promptAction, router } from '@kit.ArkUI' | import { promptAction, router } from '@kit.ArkUI' | ||||||
| import { getStepListUsingGet } from '../../api/padController' | import { getStepListUsingGet } from '../../api/padController' | ||||||
| import { CusMenuItem } from './components/MenuItem' | 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' | import Logger from '../../utils/Logger' | ||||||
| 
 | 
 | ||||||
| interface RouterParams { | interface RouterParams { | ||||||
|   lineId: number |   lineId: number | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const Tag = "[Process]" | ||||||
|  | 
 | ||||||
| @Component | @Component | ||||||
| @Entry | @Entry | ||||||
| struct Process { | struct Process { | ||||||
|   @State process: API.StepVo[] = [] |   @State process: API.StepVo[] = [] | ||||||
|   @State select: number = -1 |   @State select: number = -1 | ||||||
|   @State currentStep: number = 6 |   // @State currentStep: number = 0 | ||||||
|   private lineId: number = -1 |   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 { |   aboutToAppear(): void { | ||||||
|     const params = router.getParams() as RouterParams; |     const params = router.getParams() as RouterParams; | ||||||
| @ -25,32 +54,11 @@ struct Process { | |||||||
|     getStepListUsingGet({ lineId: this.lineId }).then(res => { |     getStepListUsingGet({ lineId: this.lineId }).then(res => { | ||||||
|       this.process = res.data || [] |       this.process = res.data || [] | ||||||
|     }) |     }) | ||||||
|     // getStageAndStepInfoUsingGet().then(res => { |     commandService.subscribe(this.onProcess) | ||||||
|     //   let len = 0 |   } | ||||||
|     //   this.process = (res.data || []).map((item) => { | 
 | ||||||
|     //     let result: API.StageAndStepRsp = { |   aboutToDisappear(): void { | ||||||
|     //       stageCode: item.stageCode, |     commandService.unsubscribe(this.onProcess) | ||||||
|     //       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 |  | ||||||
|     //   } |  | ||||||
|     // }) |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   build() { |   build() { | ||||||
| @ -84,9 +92,6 @@ struct Process { | |||||||
|                     CusMenuItem({ |                     CusMenuItem({ | ||||||
|                       step: step, |                       step: step, | ||||||
|                       index: index + 1, |                       index: index + 1, | ||||||
|                       // onSelect: (id) => { |  | ||||||
|                       //   this.select = id |  | ||||||
|                       // } |  | ||||||
|                     }) |                     }) | ||||||
|                   }) |                   }) | ||||||
|                 }.width("100%").padding({ left: 24, right: 24 }) |                 }.width("100%").padding({ left: 24, right: 24 }) | ||||||
|  | |||||||
| @ -192,14 +192,14 @@ struct Detail { | |||||||
|                     Text("左前45度照片").label() |                     Text("左前45度照片").label() | ||||||
|                   }.margin({ right: 6 }).layoutWeight(1).height("100%") |                   }.margin({ right: 6 }).layoutWeight(1).height("100%") | ||||||
| 
 | 
 | ||||||
|                   Stack({ alignContent: Alignment.TopStart }) { |                   // Stack({ alignContent: Alignment.TopStart }) { | ||||||
|                     Image(this.rightBackward) |                   //   Image(this.rightBackward) | ||||||
|                       .alt($rawfile("images/vehicle/default.png")) |                   //     .alt($rawfile("images/vehicle/default.png")) | ||||||
|                       .width("100%") |                   //     .width("100%") | ||||||
|                       .height("100%") |                   //     .height("100%") | ||||||
|                       .objectFit(ImageFit.Fill) |                   //     .objectFit(ImageFit.Fill) | ||||||
|                     Text("右后45度照片").label() |                   //   Text("右后45度照片").label() | ||||||
|                   }.margin({ left: 6 }).layoutWeight(1).height("100%") |                   // }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||||
|                 }.margin({ right: 6 }).layoutWeight(1) |                 }.margin({ right: 6 }).layoutWeight(1) | ||||||
| 
 | 
 | ||||||
|                 Row() { |                 Row() { | ||||||
| @ -223,6 +223,81 @@ struct Detail { | |||||||
|                     Text("左前45度视频").label() |                     Text("左前45度视频").label() | ||||||
|                   }.margin({ right: 6 }).layoutWeight(1).height("100%") |                   }.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 }) { |                   Stack({ alignContent: Alignment.TopStart }) { | ||||||
|                     if (this.rightBackward) { |                     if (this.rightBackward) { | ||||||
|                       VideoPlayer({ |                       VideoPlayer({ | ||||||
| @ -243,7 +318,6 @@ struct Detail { | |||||||
|                     Text("右后45度视频").label() |                     Text("右后45度视频").label() | ||||||
|                   }.margin({ left: 6 }).layoutWeight(1).height("100%") |                   }.margin({ left: 6 }).layoutWeight(1).height("100%") | ||||||
|                 }.margin({ right: 6 }).layoutWeight(1) |                 }.margin({ right: 6 }).layoutWeight(1) | ||||||
| 
 |  | ||||||
|               } |               } | ||||||
|               .width("100%") |               .width("100%") | ||||||
|               .padding({ left: 6, top: 12, bottom: 12 }) |               .padding({ left: 6, top: 12, bottom: 12 }) | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import { util } from '@kit.ArkTS'; | |||||||
| 
 | 
 | ||||||
| const Tag = "CommandService" | const Tag = "CommandService" | ||||||
| 
 | 
 | ||||||
| interface Message<T = Object> { | export interface Message<T = Object> { | ||||||
|   type: CommandType |   type: CommandType | ||||||
|   reqCode: string |   reqCode: string | ||||||
|   body: T |   body: T | ||||||
| @ -22,15 +22,22 @@ interface CommandBody { | |||||||
|   name: string |   name: string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| interface ResponseMessage { | export interface ResponseMessage { | ||||||
|   code: string |   code: string | ||||||
|   msg: string |   msg: string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| enum CommandType { | export interface PostCurrentStepMessage { | ||||||
|  |   lineId: string | ||||||
|  |   stepCode: string | ||||||
|  |   stepName: string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export enum CommandType { | ||||||
|   HandleAlarm = "handleAlarm", |   HandleAlarm = "handleAlarm", | ||||||
|   PostCmd = "postCmd", |   PostCmd = "postCmd", | ||||||
|   PostCmdRsp = "postCmdRsp" |   PostCmdRsp = "postCmdRsp", | ||||||
|  |   PostCurrentStep = "postCurrentStep" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export enum CommandCode { | export enum CommandCode { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user