/* */ // 自定义指令 const CustomDirectives = (function () { const create = () => ({ icStuckStatus: '', // IC卡关状态 (0:关;1:开) switch58GANTStatus: '', // 开关5.8G天线状态 (0:关;1:开) voiceSupported: '', // 是否支持语音 (0:不支持;1:支持) batteryLevel: 100, // 电池电量 // 克隆方法 clone: function () { return CustomDirectives.create().init(this); }, init: function (source) { Object.assign(this, { icStuckStatus: source.icStuckStatus || '', switch58GANTStatus: source.switch58GANTStatus || '', voiceSupported: source.voiceSupported || '', batteryLevel: source.batteryLevel || '' }); return this; } }); return { create }; })(); // 国家标准蓝牙设备信息 const BleDeviceInfo = (function () { const create = () => ({ deviceNumber: '', // 设备编号 versionNumber: '', // 版本号:2 字节。ESAM 系统信息第 9-10 字节(即 OBU 的协约类型和合同版本) batteryLevel: '', // 蓝牙 OBU 电量:1byte,00 代表低电,0x64 代表正常,车载供电模式使用0xFF contractNumber: '', // 合同序列号 OBU SAM 合同序号(盒子表面印刷号) obuMca: '', // 4 字节 OBU MAC 地址 obuVersion: '', // 4 字节 OBU 版本号 deviceTamperStatus: 0, // 设备防拆状态 1 字节防拆状态:0-拆卸,1-未拆卸 disassemble: 0, // 防拆柱状态 1-压下,0-弹起 // 克隆方法 clone: function () { return BleDeviceInfo.create() .init(this); }, init: function (source) { Object.assign(this, { deviceNumber: source.deviceNumber || '', versionNumber: source.versionNumber || '', batteryLevel: source.batteryLevel || '', contractNumber: source.contractNumber || '', obuMca: source.obuMca || '', obuVersion: source.obuVersion || '', deviceTamperStatus: source.deviceTamperStatus || '', disassemble: source.disassemble || '' }); return this; } }); return { create }; })(); // 发行商信息对象(优化版) const OBUIssuerInfo = (function () { const create = (identity) => ({ issuerIdentity: '', // 发卡方标识 agreementType: '', // 协约类型 contractVersion: '', // 合同版本 contractNumber: '', // 合同序列号 signedDate: '', // 启用日期(yyyy-MM-dd) expiredDate: '', // 过期日期 tamperEvidentStatus: '', // 防拆状态 00-非法拆卸,1-正常 // 克隆方法 clone: function () { return OBUIssuerInfo.create(this.issuerIdentity) .init(this); }, init: function (source) { Object.assign(this, { issuerIdentity: source.issuerIdentity || '', agreementType: source.agreementType || '', contractVersion: source.contractVersion || '', contractNumber: source.contractNumber || '', signedDate: source.signedDate || '', expiredDate: source.expiredDate || '', tamperEvidentStatus: source.tamperEvidentStatus || '' }); return this; } }); return { create }; })(); // 发行商信息对象(优化版) const ICCIssuerInfo = (function () { const create = (identity) => ({ issuerIdentity: '', // 发卡方标识 cardType: '', // 卡片类型(22-储值卡,23-记账卡) cardVersion: '', // 卡片版本号 cardNetId: '', // 卡片网络编号 cpuCardInnerId: '', // CPU卡内部编号 signedDate: '', // 启动时间 expiredDate: '', // 到期时间 plateNo: '', // 车牌号(原vehicleInfo.plateNo) userType: '', // 用户类型 plateColor: '', // 车牌颜色(原vehicleInfo.plateColor) vehicleModel: '', // 国标车型(原vehicleInfo.vehicleType) // 克隆方法 clone: function () { return ICCIssuerInfo.create(this.issuerIdentity) .init(this); }, init: function (source) { Object.assign(this, { cardType: source.cardType || '', cardVersion: source.cardVersion || '', cardNetId: source.cardNetId || '', cpuCardInnerId: source.cpuCardInnerId || '', signedDate: source.signedDate || '', expiredDate: source.expiredDate || '', plateNo: source.plateNo || '', userType: source.userType || '', plateColor: source.plateColor || '', vehicleModel: source.vehicleType || '' }); return this; } }); return { create }; })(); // 收费站通行信息对象 const StationPassInfo = (function () { const create = (roadNetId, stationId) => ({ roadNetId: '', // 路网编号 stationId: '', // 收费站编号 laneId: 0, // 车道号 passTime: new Date(),// 通过时间(Date对象) vehicleType: 0, // 车型 state: 0, // 状态(01-入口,02-出口) tollCollectorId: '',// 收费员工号 classOrder: 0, // 班次 // 克隆方法 clone: function () { return StationPassInfo.create( this.roadNetId, this.stationId ).initPassData(this); }, initPassData: function (data) { this.vehicleType = data.vehicleType || 0; this.state = data.state || 0; this.tollCollectorId = data.tollCollectorId || ''; return this; } }); return { create }; })(); // 车辆尺寸对象 const VehicleDimension = (function () { // 工厂函数创建实例 const create = (length, width, height) => ({ length: 0, // 单位dm width: 0, // 单位dm height: 0, // 单位dm // 初始化方法 init: (l, w, h) => { Object.assign(this, { length: l, width: w, height: h }); return this; }, // 克隆方法 clone: function () { return VehicleDimension.create( this.length, this.width, this.height ); } }); return { create }; })(); // OBU车辆信息对象 const ObuVehicleInfo = (function () { // 车辆类型枚举 const VEHICLE_TYPES = { TYPE_1: 1, // 一型车 TYPE_2: 2, // 二型车 // ...其他类型 }; // 用户类型枚举 const USER_TYPES = { NORMAL: 0, // 普通车 COMMERCIAL: 6,// 商务车 // ...其他类型 }; const create = (plateNo, plateColor, type) => ({ plateNo: '', // 车牌号 plateColor: '', // 车辆颜色(0-5) plateType: 0, // 车型(1-6) userType: USER_TYPES.NORMAL, plateSize: VehicleDimension.create(0, 0, 0), wheelNum: 0, // 车轮数 axleNum: 0, // 车轴数 wheelbase: 0, // 轴距(dm) loadAndSeatNum: 0, // 载重/座位数 characteristic: '', // 特征 engineNo: '', // 发动机编号 // 初始化方法 init: (params) => { Object.assign(this, params); this.plateSize.init( params.plateSize.length || 0, params.plateSize.width || 0, params.plateSize.height || 0 ); return this; }, // 克隆方法 clone: function () { return ObuVehicleInfo.create( this.plateNo, this.plateColor, this.plateType ).init(this); } }); return { create }; })(); // 主对象定义 const EtcVehicleInfo = (function () { const create = (obuid) => ({ obuid: obuid || '', // OBUID // 状态标志 isRemove: false, // 是否被拆卸 0-true-拆卸,1-false-未拆卸 obuRemoveStatus:'00', // 是否被拆卸 00-拆卸,01-未拆卸 iccExists: false, // IC卡存在状态 true-存在,false-无IC卡 // 数据字段 encryptedVehicleInfoFile: '', // 加密文件(16进制字符串) cardType: 0, // 业务系统卡类型 transType: 0, // 交易类型 cardRestMoney: 0, // 卡余额(单位:分) icCardNumber:'', // IC卡号(卡片网络编号 + CPU卡内部编号) // 嵌套对象 obuIssuer: OBUIssuerInfo.create(''), // OBU发行商信息 icIssuer: ICCIssuerInfo.create(''), // IC卡发行商信息 lastStation: StationPassInfo.create('', ''), // 上次过站 obuVehicle: ObuVehicleInfo.create('', '', 0), // OBU车辆信息 vehicleInfoDe: '', // 解密明文 vehicleClass: '', // 车型 obuActivationStatus: "00", // 激活状态(00:未激活,01:激活) customDirectives:CustomDirectives.create(), bleDeviceInfo:BleDeviceInfo.create(), // 克隆方法 clone: function () { return EtcVehicleInfo.create(this.obuid) .initAll(this); }, initAll: function (source) { // 初始化所有嵌套对象 this.obuIssuer.init(source.obuIssuer); this.icIssuer.init(source.icIssuer); this.lastStation.init(source.lastStation); this.obuVehicle.init(source.obuVehicle); this.customDirectives.init(source.customDirectives); this.bleDeviceInfo.init(source.bleDeviceInfo); return this; } }); return { create }; })(); // 导出模块 export default { EtcVehicleInfo, VehicleDimension, OBUIssuerInfo, ICCIssuerInfo, StationPassInfo, ObuVehicleInfo, CustomDirectives, BleDeviceInfo };