合并dev代码
This commit is contained in:
		
							parent
							
								
									73bc75388f
								
							
						
					
					
						commit
						21a1f20cef
					
				
							
								
								
									
										73
									
								
								entry/src/main/ets/common/utils/UdpEvent.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								entry/src/main/ets/common/utils/UdpEvent.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,73 @@ | ||||
| import emitter from '@ohos.events.emitter'; | ||||
| 
 | ||||
| export const EVENTID = { | ||||
|   //远程扣分处理 | ||||
|   kfEventId:35, | ||||
|   //远程扣分查询 | ||||
|   kfAskEventId:36, | ||||
|   //远程扣分确认 | ||||
|   kfConfirmEventId:37, | ||||
|   //远程开始考试 | ||||
|   beginExamEventId:11, | ||||
|   //远程结束考试 | ||||
|   endExamEventId:12 | ||||
| } | ||||
| 
 | ||||
| export default class JudgeEmitter{ | ||||
| 
 | ||||
|   private beginExamCallBack:Function = ()=>{} | ||||
|   private endExamCallBack:Function = ()=>{} | ||||
| 
 | ||||
|   constructor() { | ||||
|     this.init() | ||||
|   } | ||||
| 
 | ||||
|   init = async ()=>{ | ||||
|     console.info('surenjun','开始注册udp事件') | ||||
|     emitter.on({eventId:EVENTID.beginExamEventId}, () => { | ||||
|       this?.beginExamCallBack() | ||||
|     }); | ||||
|     emitter.on({eventId:EVENTID.endExamEventId}, () => { | ||||
|       this?.endExamCallBack() | ||||
|     }); | ||||
|     emitter.on({eventId:EVENTID.kfEventId}, () => { | ||||
|       this?.endExamCallBack() | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   //监听开始考试 | ||||
|   public onBeginExam = async (callBack?:Function)=>{ | ||||
|     console.info('surenjun','userInfo注册onBeginExam事件') | ||||
|     this.beginExamCallBack = callBack | ||||
|   } | ||||
| 
 | ||||
|   //监听结束考试 | ||||
|   public onEndExam = async (callBack?:Function)=>{ | ||||
|     this.endExamCallBack = callBack | ||||
|   } | ||||
| 
 | ||||
|   //监听扣分处理 | ||||
|   public onKfExam= async (callBack?:Function)=>{ | ||||
|     this.endExamCallBack = callBack | ||||
|   } | ||||
| 
 | ||||
|   //开始考试 | ||||
|   public sendBeginExam = async(content:string)=>{ | ||||
|     emitter.emit({eventId:EVENTID.beginExamEventId}, { | ||||
|       data:{ content } | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   //结束考试 | ||||
|   public sendEndExam = async(content:string)=>{ | ||||
|     emitter.emit({eventId:EVENTID.endExamEventId}, { | ||||
|       data:{content} | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										165
									
								
								entry/src/main/ets/mock/CarCheck.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								entry/src/main/ets/mock/CarCheck.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,165 @@ | ||||
| export const WarnFlagData = { | ||||
|   1: '0', | ||||
|   2: '0', | ||||
|   3: '0', | ||||
|   4: '0', | ||||
|   5: '0', | ||||
|   6: '0', | ||||
|   7: '0', | ||||
|   8: '0', | ||||
|   9: '0', | ||||
|   10: '0', | ||||
|   11: '0', | ||||
|   12: '0', | ||||
|   13: '0', | ||||
|   14: '0', | ||||
|   15: '0', | ||||
|   16: '0', | ||||
|   17: '0', | ||||
|   18: '0', | ||||
|   19: '0', | ||||
|   20: '0', | ||||
|   21: '0', | ||||
|   22: '0', | ||||
|   23: '0', | ||||
|   24: '0', | ||||
|   25: '0', | ||||
|   26: '0', | ||||
|   27: '0', | ||||
|   28: '0', | ||||
|   29: '0', | ||||
| } | ||||
| 
 | ||||
| export const PassData = { | ||||
|   1: false, | ||||
|   2: false, | ||||
|   3: false, | ||||
|   4: false, | ||||
|   5: false, | ||||
|   6: false, | ||||
|   7: false, | ||||
|   8: false, | ||||
|   9: false, | ||||
|   10: false, | ||||
|   11: false, | ||||
|   12: false, | ||||
|   13: false, | ||||
|   14: false, | ||||
|   15: false, | ||||
|   16: false, | ||||
|   17: false, | ||||
|   18: false, | ||||
|   19: false, | ||||
|   20: false, | ||||
|   21: false, | ||||
|   22: false, | ||||
|   23: false, | ||||
|   24: false, | ||||
|   25: false, | ||||
|   26: false, | ||||
|   27: false, | ||||
|   28: false, | ||||
|   29: false, | ||||
| } | ||||
| 
 | ||||
| export const StackValueData = { | ||||
|   1: '', | ||||
|   2: "", | ||||
|   3: "", | ||||
|   4: "", | ||||
|   5: "", | ||||
|   6: "", | ||||
|   7: "", | ||||
|   8: "", | ||||
|   9: "", | ||||
|   10: "", | ||||
|   11: "", | ||||
|   12: "", | ||||
|   13: "", | ||||
|   14: "", | ||||
|   15: "", | ||||
|   16: "", | ||||
|   17: "", | ||||
|   18: "", | ||||
|   19: "", | ||||
|   20: "", | ||||
|   21: "", | ||||
|   22: "", | ||||
|   23: "", | ||||
|   24: "", | ||||
|   25: "", | ||||
|   26: "", | ||||
|   27: "", | ||||
|   28: "", | ||||
|   29: "", | ||||
| } | ||||
| 
 | ||||
| export const WarnFlagTipData = { | ||||
|   0: [], | ||||
|   1: [], | ||||
|   2: [], | ||||
|   3: ['check1.wav', 'check2.wav'], | ||||
|   4: ['check3.wav', 'check4.wav'], | ||||
|   5: ['check5.wav', 'check6.wav'], | ||||
|   6: ['check7.wav', 'check8.wav'], | ||||
|   7: ['check9.wav', 'check10.wav'], | ||||
|   8: ['check26.wav', 'check27.wav'], | ||||
|   9: ['dianhuoVideo.wav', 'xihuoVideo.wav'], | ||||
|   10: ['check31.wav'], | ||||
|   11: ['check30.wav'], | ||||
|   12: ['check28.wav'], | ||||
|   13: ['check29.wav'], | ||||
|   14: ['check11.wav'], | ||||
|   15: ['check12.wav'], | ||||
|   16: ['check13.wav'], | ||||
|   17: ['check14.wav'], | ||||
|   18: ['check15.wav'], | ||||
|   19: ['check16.wav'], | ||||
|   20: ['check17.wav'], | ||||
|   21: ['check18.wav'], | ||||
|   22: ['check19.wav'], | ||||
|   23: ['check22.wav'], | ||||
|   24: ['check23.wav'], | ||||
|   25: ['check20.wav', 'check21.wav'], | ||||
|   26: ['check24.wav'], | ||||
|   // 27:[],
 | ||||
|   // 28:[],
 | ||||
|   // 29:[],
 | ||||
| } | ||||
| 
 | ||||
| export const RealNumData = { | ||||
|   3: 19, | ||||
|   4: 17, | ||||
|   5: 13, | ||||
|   6: 12, | ||||
|   7: 14, | ||||
|   8: 18, | ||||
|   9: 5, | ||||
|   10: 29, | ||||
|   11: 30, | ||||
|   12: 31, | ||||
|   13: 32, | ||||
|   14: 28, | ||||
|   15: 28, | ||||
|   16: 28, | ||||
|   17: 28, | ||||
|   18: 28, | ||||
|   19: 28, | ||||
|   20: 28, | ||||
|   21: 2, //左方向灯,
 | ||||
|   22: 3, | ||||
|   23: 7, | ||||
|   24: 8, | ||||
|   25: 20, | ||||
|   26: '' | ||||
| } | ||||
| 
 | ||||
| export const DwMapData={ | ||||
|   14: '1', | ||||
|   15: '2', | ||||
|   16: '3', | ||||
|   17: '4', | ||||
|   18: '5', | ||||
|   19: '9', | ||||
|   20: '0' | ||||
| } | ||||
							
								
								
									
										35
									
								
								entry/src/main/ets/mock/VideoData.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								entry/src/main/ets/mock/VideoData.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| import { VideoConfig } from '../pages/interfaces' | ||||
| 
 | ||||
| // 视频配置默认数据
 | ||||
| export const VideoConfigData: VideoConfig = { | ||||
|   videoNum: '1', | ||||
|   spls: '1', | ||||
|   wz: '0,0', | ||||
|   faceFlag: false, | ||||
|   shuiying: true, | ||||
|   pztd: '2', | ||||
|   ljlx: '', | ||||
|   ip: '192.168.7.112', | ||||
|   port: '554', | ||||
|   userName: 'admin', | ||||
|   pwd: '12345qwe', | ||||
|   td1: '1', | ||||
|   td2: '2', | ||||
|   td3: '3', | ||||
|   td4: '4', | ||||
|   videoRecord1: false, | ||||
|   videoRecord2: false, | ||||
|   videoRecord3: false, | ||||
|   videoRecord4: false, | ||||
|   text1: '', | ||||
|   text2: '', | ||||
|   text3: '', | ||||
|   dolt: '', | ||||
|   fontSize: '', | ||||
|   rlls: '1', | ||||
|   spzd4: false, | ||||
|   spzd3: false, | ||||
|   spzd2: false, | ||||
|   spzd1: false, | ||||
|   zdyz: '5', | ||||
| } | ||||
							
								
								
									
										9
									
								
								entry/src/main/ets/mock/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								entry/src/main/ets/mock/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| export * from "./CandidateData" | ||||
| 
 | ||||
| export * from "./VideoData" | ||||
| 
 | ||||
| export * from "./Judge" | ||||
| 
 | ||||
| export * from "./SignDisplay" | ||||
| 
 | ||||
| export * from "./CarCheck" | ||||
							
								
								
									
										25
									
								
								entry/src/main/ets/pages/compontents/judge/video-play.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								entry/src/main/ets/pages/compontents/judge/video-play.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| 
 | ||||
| @Component | ||||
| export default struct EndPopup { | ||||
|   constructor() { | ||||
|     super() | ||||
|   } | ||||
| 
 | ||||
|   private title:string = '' | ||||
|   private cancelFn:(event?: ClickEvent) => void | ||||
|   private confirmFn:(event?: ClickEvent) => void | ||||
| 
 | ||||
|   build(){ | ||||
|     Column(){ | ||||
|       Column(){ | ||||
|         Text(this.title).fontSize(38).margin({bottom:20}) | ||||
|         Row(){}.height(50) | ||||
|         Row(){ | ||||
|           Text('取消').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(100).fontSize(30).fontColor('#FFF').textAlign(TextAlign.Center).onClick(this.cancelFn) | ||||
|           Text('确定').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(100).fontSize(30).fontColor('#FFF').textAlign(TextAlign.Center).margin({left:45}).onClick(this.confirmFn) | ||||
|         } | ||||
|       }.width('80%').height('70%').backgroundColor('#E6E3DF').borderRadius(38).position({y:'12%',x:'10%'}).justifyContent(FlexAlign.Center) | ||||
| 
 | ||||
|     }.width('100%').height('100%').position({y:0}).backgroundColor('rgba(0,0,0,0.7)') | ||||
|   } | ||||
| } | ||||
							
								
								
									
										155
									
								
								entry/src/main/ets/pages/judgeSDK/dataTest/GpsPort.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								entry/src/main/ets/pages/judgeSDK/dataTest/GpsPort.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,155 @@ | ||||
| package com.duolun.vehterminal.dl_frontend.port; | ||||
| 
 | ||||
| 
 | ||||
| import android.text.TextUtils; | ||||
| import android.util.Log; | ||||
| 
 | ||||
| import com.duolun.vehterminal.dl_base.config.ExamParam; | ||||
| import com.duolun.vehterminal.dl_base.log.LogHelper; | ||||
| import com.duolun.vehterminal.dl_library.SensorCache; | ||||
| import com.duolun.vehterminal.dl_library.VehicleStatus; | ||||
| import com.duolun.vehterminal.dl_library.bean.GPSInfo; | ||||
| import java.math.BigDecimal; | ||||
| import java.nio.charset.StandardCharsets; | ||||
| 
 | ||||
| public class GpsPort extends Port{ | ||||
| 
 | ||||
|     private final String TAG = "GpsPort"; | ||||
| 
 | ||||
|     private StringBuffer gpsData = new StringBuffer(); | ||||
| 
 | ||||
|     private long start = System.currentTimeMillis(); | ||||
| 
 | ||||
|     public void start() { | ||||
|         super.start(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     protected void handleData() { | ||||
|         try { | ||||
|             //client.send("hello!".getBytes()); | ||||
|             byte[] msg = client.receive(); | ||||
|             if(msg == null) return; | ||||
|             String revMsg = new String(msg, "US-ASCII").trim(); | ||||
|             String obdData = SensorCache.getInstance().getObdData(); | ||||
|             SensorCache.getInstance().setPlcData(obdData + revMsg); | ||||
| 
 | ||||
|             if(TextUtils.isEmpty(revMsg)) return; | ||||
|             long timeLen = System.currentTimeMillis() - start; | ||||
|            // Log.e(TAG,"----------------revMsg--->"+revMsg); | ||||
|             if(timeLen>100){ | ||||
|                 if(!TextUtils.isEmpty(gpsData.toString())){ | ||||
|                     GPSInfo info = getGPSInfo(gpsData.toString()); | ||||
|                     if (info != null) { | ||||
|                         if (info.getMode() == 4) { | ||||
|                             VehicleStatus.status[VehicleStatus.GPS] = VehicleStatus.NORMAL; | ||||
|                         } else { | ||||
|                             VehicleStatus.status[VehicleStatus.GPS] = VehicleStatus.EXCEPTION; | ||||
|                         } | ||||
|                         SensorCache.getInstance().putGpsInfo(info); | ||||
|                     } | ||||
|                 } | ||||
|                 gpsData = new StringBuffer(); | ||||
|                 gpsData.append(revMsg); | ||||
|             }else{ | ||||
|                 gpsData.append(revMsg); | ||||
|             } | ||||
|             start = System.currentTimeMillis(); | ||||
|         } catch (Exception e) { | ||||
|            LogHelper.e(TAG,"",e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     private GPSInfo getGPSInfo(String data) { | ||||
|         LogHelper.i(TAG, "getGPSInfo--->"+data); | ||||
|         GPSInfo info = new GPSInfo(); | ||||
|         info.setGpsFrontNum(1); | ||||
|         try { | ||||
|             String[] lines = data.split("\r\n"); | ||||
|             for(String line:lines){ | ||||
|                 if(line.startsWith("$KSXT")){ | ||||
|                     getGPS(info,line); | ||||
|                 }else if(line.startsWith("$GPGST")){ | ||||
|                     String[] _data = line.split(","); | ||||
|                     info.setLatErrorValue(Float.parseFloat(TextUtils.isEmpty(_data[6]) ? "0" : _data[6]));//维度精度因子 | ||||
|                     info.setLongErrorValue(Float.parseFloat(TextUtils.isEmpty(_data[7]) ? "0" : _data[7]));//经度精度因子 | ||||
|                     info.setHeightErrorValue(Float.parseFloat(_data[8].split("\\*")[0])); | ||||
|                 }else if(line.startsWith("#HEADINGA")){ | ||||
|                     String[] strs = line.split(","); | ||||
|                     BigDecimal b = new BigDecimal(Float.parseFloat(strs[12])); | ||||
|                     float azimuthAngle = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); | ||||
|                     azimuthAngle += 180; | ||||
|                     if (azimuthAngle > 360) { | ||||
|                         azimuthAngle = azimuthAngle - 360; | ||||
|                     } | ||||
|                     info.setAzimuthAngle(azimuthAngle); | ||||
|                     BigDecimal d = new BigDecimal(Float.parseFloat(strs[13])); | ||||
|                     info.setPitchAngle(d.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue()); | ||||
|                     info.setAzimuthAngleErrorValue(Float.parseFloat(strs[15])); | ||||
|                     info.setPitchAngleErrorValue(Float.parseFloat(strs[16])); | ||||
|                 }else if(line.startsWith("$GPGGA")){ | ||||
|                     String[] gps = line.split(","); | ||||
|                     int status = Integer.parseInt(TextUtils.isEmpty(gps[6]) ? "0" : gps[6]);//状态 | ||||
|                     if (status > 0) info.setStatus(1); | ||||
|                     info.setMode(status); | ||||
|                     info.setLocationStatus(status + ""); | ||||
|                 } | ||||
|             } | ||||
|             info.setGpsData(data); | ||||
|             SensorCache.getInstance().putGpsInfo(info); | ||||
|         } catch (Exception e) { | ||||
|             LogHelper.e(TAG, "getGPSInfo->", e); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     private void getGPS(GPSInfo gpsInfo,String signal) { | ||||
|         try { | ||||
|             String[] gps = signal.split(","); | ||||
|             if (gps.length < 14) { | ||||
|                 gpsInfo.setRevTime(System.currentTimeMillis()); | ||||
|                 SensorCache.getInstance().putGpsInfo(gpsInfo); | ||||
|                 LogHelper.i(TAG,signal); | ||||
|                 return; | ||||
|             } | ||||
|             gpsInfo.setMsg("#GPS," + signal); | ||||
|             gpsInfo.setRevTime(System.currentTimeMillis()); | ||||
|             gpsInfo.setAzimuthStatus(gps[11]); | ||||
|             gpsInfo.setAzimuthNum(gps[12]); | ||||
|             gpsInfo.setGpsFrontNum(Integer.parseInt(TextUtils.isEmpty(gps[13]) ? "0" : gps[13]));//收星数 | ||||
|             gpsInfo.setHeight(Float.parseFloat(TextUtils.isEmpty(gps[4]) ? "0" : gps[4]));//海拔高度 | ||||
|             gpsInfo.setAge(Float.parseFloat(TextUtils.isEmpty(gps[20]) ? "0" : gps[20]));//龄期 | ||||
|             String pitchAngle = gps[6];//俯仰角 | ||||
|             gpsInfo.setPitchAngle(Float.parseFloat(TextUtils.isEmpty(pitchAngle) ? "0" : pitchAngle)); | ||||
|             gpsInfo.setGpsTime(gps[1]); | ||||
|             gpsInfo.setLatitude(Double.parseDouble(TextUtils.isEmpty(gps[3]) ? "0" : gps[3]));//维度 | ||||
|             gpsInfo.setLongitude(Double.parseDouble(TextUtils.isEmpty(gps[2]) ? "0" : gps[2]));//精度 | ||||
|             float speed = 0; | ||||
|             if (gps.length>14 && !TextUtils.isEmpty(gps[8])) { | ||||
|                 BigDecimal r = new BigDecimal(Float.parseFloat(gps[8]) * 1.852); | ||||
|                 speed = r.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); | ||||
|                 gpsInfo.setVelocity(speed); | ||||
|             } | ||||
|             if ("0".equals(ExamParam.SPEED_TYPE) || TextUtils.isEmpty(ExamParam.SPEED_TYPE)) | ||||
|                 ExamParam.SPEED = speed + ""; | ||||
|         } catch (Exception e) { | ||||
|             LogHelper.i5(TAG, "异常数据:" + signal); | ||||
|             LogHelper.i5(TAG, "异常信息:"+e.getMessage()); | ||||
|             gpsInfo.setRevTime(System.currentTimeMillis()); | ||||
|             SensorCache.getInstance().putGpsInfo(gpsInfo); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 坐标预处理,将度分转为度 | ||||
|      * | ||||
|      * @return | ||||
|      */ | ||||
|     private double translateLatLon(double a) { | ||||
|         int temp1 = (int) Math.floor(a / 100); | ||||
|         double temp2 = temp1 + (a - temp1 * 100) / 60; | ||||
|         return temp2; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,9 @@ | ||||
| Find GPGST,Find GPRMC,Find GPGGA,Find PTNL,Find BESTPOSA,Find HEADINGA,Find KSXT,Find BYC, | ||||
| $GPGST,045215.20,0.03,0.01,0.03,0.0000,0.01,0.01,0.03*60 | ||||
| $GPRMC,045215.20,A,3206.3460589,N,11842.1399062,E,0.022,0.0,081024,0.0,E,D*30 | ||||
| $GPGGA,045215.20,3206.3460589,N,11842.1399062,E,4,42,0.5,1.935,M,0.592,M,3.200,0000*7A | ||||
| $PTNL,AVR,045215.20,+66.5809,Yaw,-1.1687,Tilt,,,1.288,3,1.2,38*01 | ||||
| $KSXT,20241008045215.20,118.70233177,32.10576765,2.5270,66.58,-1.17,70.35,0.040,,3,3,38,42,-45.675,-21.352,-2.137,0.038,0.013,0.015,3.2,40,*8BA53C1A | ||||
| #BESTPOSA,COM1,0,87.5,FINESTEERING,2335,190353.200,00000000,0000,782;SOL_COMPUTED,NARROW_INT,32.10576764819,118.70233176936,1.9353,0.5917,WGS84,0.0132,0.0118,0.0253,"0",3.200,0.034,44,42,42,42,00,00,30,37*77b805ad | ||||
| #HEADINGA,COM1,0,87.5,FINESTEERING,2335,190353.200,00000000,0000,782;SOL_COMPUTED,NARROW_INT,1.287597299,66.580940247,-1.168731809,0.0,0.808748186,0.807274878,"0",44,38,44,26,0,00,30,37*3e44d092 | ||||
| #BYCHECKA,COM1,0,87.5,FINESTEERING,2335,190353.200,00000000,0000,782;1268,2335,190353.200,1,1,1,0,1,1,1,1,1,1,1,1*c786fc2a | ||||
							
								
								
									
										58
									
								
								entry/src/main/ets/pages/judgeSDK/utils/judgeTask_BAK.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								entry/src/main/ets/pages/judgeSDK/utils/judgeTask_BAK.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| import Prompt from '@system.prompt' | ||||
| 
 | ||||
| const TAG = 'SURENJUN_JUDGE' | ||||
| interface QUEUE{ | ||||
|   fn:Function, | ||||
|   config?:{ | ||||
|     isDelay:boolean | ||||
|     delayTime:number | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| export default class JudgeTask{ | ||||
|   private queue = [] | ||||
|   private status:string | ||||
|   constructor() { | ||||
|     this.queue = [] | ||||
|     this.status = 'end' | ||||
|   } | ||||
| 
 | ||||
|   executeQueue = async ()=>{ | ||||
|     const {queue,executeQueue} = this | ||||
|     if(queue.length){ | ||||
|       for (const currentTask of queue) { | ||||
|         const {fn,delayConfig:{ | ||||
|           isDelay = false, | ||||
|           delayTime = 1000 | ||||
|         }} = currentTask; | ||||
|         const {status} = this | ||||
|         try { | ||||
|           isDelay | ||||
|             ?setTimeout(async ()=>{await fn()}) | ||||
|             :await fn(); | ||||
|         }catch (e){ | ||||
|           // console.info(TAG,'过程数据接口解析错误')
 | ||||
|           Prompt.showToast({ | ||||
|             message: '过程数据接口解析错误', | ||||
|             duration: 3000 | ||||
|           }); | ||||
|         } | ||||
|         this.queue.shift() | ||||
|         await executeQueue() | ||||
|       } | ||||
|     }else{ | ||||
|       this.status = 'end' | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   addTask = async (fn,delayConfig?:{ | ||||
|     isDelay:Boolean, | ||||
|     delayTime:Number | ||||
|   }) =>{ | ||||
|     this.queue.push({fn,delayConfig}); | ||||
|     if(this.status == 'end' && this.queue.length === 1){ | ||||
|       await this.executeQueue(); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										2
									
								
								entry/src/main/ets/pages/judgeSDK/utils/rearEndUni.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								entry/src/main/ets/pages/judgeSDK/utils/rearEndUni.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| 
 | ||||
| //
 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user