Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

kcEtcVehicleInfo.js 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /*
  2. */
  3. // 自定义指令
  4. const CustomDirectives = (function () {
  5. const create = () => ({
  6. icStuckStatus: '', // IC卡关状态 (0:关;1:开)
  7. switch58GANTStatus: '', // 开关5.8G天线状态 (0:关;1:开)
  8. voiceSupported: '', // 是否支持语音 (0:不支持;1:支持)
  9. batteryLevel: 100, // 电池电量
  10. // 克隆方法
  11. clone: function () {
  12. return CustomDirectives.create().init(this);
  13. },
  14. init: function (source) {
  15. Object.assign(this, {
  16. icStuckStatus: source.icStuckStatus || '',
  17. switch58GANTStatus: source.switch58GANTStatus || '',
  18. voiceSupported: source.voiceSupported || '',
  19. batteryLevel: source.batteryLevel || ''
  20. });
  21. return this;
  22. }
  23. });
  24. return { create };
  25. })();
  26. // 国家标准蓝牙设备信息
  27. const BleDeviceInfo = (function () {
  28. const create = () => ({
  29. deviceNumber: '', // 设备编号
  30. versionNumber: '', // 版本号:2 字节。ESAM 系统信息第 9-10 字节(即 OBU 的协约类型和合同版本)
  31. batteryLevel: '', // 蓝牙 OBU 电量:1byte,00 代表低电,0x64 代表正常,车载供电模式使用0xFF
  32. contractNumber: '', // 合同序列号 OBU SAM 合同序号(盒子表面印刷号)
  33. obuMca: '', // 4 字节 OBU MAC 地址
  34. obuVersion: '', // 4 字节 OBU 版本号
  35. deviceTamperStatus: 0, // 设备防拆状态 1 字节防拆状态:0-拆卸,1-未拆卸
  36. disassemble: 0, // 防拆柱状态 1-压下,0-弹起
  37. // 克隆方法
  38. clone: function () {
  39. return BleDeviceInfo.create()
  40. .init(this);
  41. },
  42. init: function (source) {
  43. Object.assign(this, {
  44. deviceNumber: source.deviceNumber || '',
  45. versionNumber: source.versionNumber || '',
  46. batteryLevel: source.batteryLevel || '',
  47. contractNumber: source.contractNumber || '',
  48. obuMca: source.obuMca || '',
  49. obuVersion: source.obuVersion || '',
  50. deviceTamperStatus: source.deviceTamperStatus || '',
  51. disassemble: source.disassemble || ''
  52. });
  53. return this;
  54. }
  55. });
  56. return { create };
  57. })();
  58. // 发行商信息对象(优化版)
  59. const OBUIssuerInfo = (function () {
  60. const create = (identity) => ({
  61. issuerIdentity: '', // 发卡方标识
  62. agreementType: '', // 协约类型
  63. contractVersion: '', // 合同版本
  64. contractNumber: '', // 合同序列号
  65. signedDate: '', // 启用日期(yyyy-MM-dd)
  66. expiredDate: '', // 过期日期
  67. tamperEvidentStatus: '', // 防拆状态 00-非法拆卸,1-正常
  68. // 克隆方法
  69. clone: function () {
  70. return OBUIssuerInfo.create(this.issuerIdentity)
  71. .init(this);
  72. },
  73. init: function (source) {
  74. Object.assign(this, {
  75. issuerIdentity: source.issuerIdentity || '',
  76. agreementType: source.agreementType || '',
  77. contractVersion: source.contractVersion || '',
  78. contractNumber: source.contractNumber || '',
  79. signedDate: source.signedDate || '',
  80. expiredDate: source.expiredDate || '',
  81. tamperEvidentStatus: source.tamperEvidentStatus || ''
  82. });
  83. return this;
  84. }
  85. });
  86. return { create };
  87. })();
  88. // 发行商信息对象(优化版)
  89. const ICCIssuerInfo = (function () {
  90. const create = (identity) => ({
  91. issuerIdentity: '', // 发卡方标识
  92. cardType: '', // 卡片类型(22-储值卡,23-记账卡)
  93. cardVersion: '', // 卡片版本号
  94. cardNetId: '', // 卡片网络编号
  95. cpuCardInnerId: '', // CPU卡内部编号
  96. signedDate: '', // 启动时间
  97. expiredDate: '', // 到期时间
  98. plateNo: '', // 车牌号(原vehicleInfo.plateNo)
  99. userType: '', // 用户类型
  100. plateColor: '', // 车牌颜色(原vehicleInfo.plateColor)
  101. vehicleModel: '', // 国标车型(原vehicleInfo.vehicleType)
  102. // 克隆方法
  103. clone: function () {
  104. return ICCIssuerInfo.create(this.issuerIdentity)
  105. .init(this);
  106. },
  107. init: function (source) {
  108. Object.assign(this, {
  109. cardType: source.cardType || '',
  110. cardVersion: source.cardVersion || '',
  111. cardNetId: source.cardNetId || '',
  112. cpuCardInnerId: source.cpuCardInnerId || '',
  113. signedDate: source.signedDate || '',
  114. expiredDate: source.expiredDate || '',
  115. plateNo: source.plateNo || '',
  116. userType: source.userType || '',
  117. plateColor: source.plateColor || '',
  118. vehicleModel: source.vehicleType || ''
  119. });
  120. return this;
  121. }
  122. });
  123. return { create };
  124. })();
  125. // 收费站通行信息对象
  126. const StationPassInfo = (function () {
  127. const create = (roadNetId, stationId) => ({
  128. roadNetId: '', // 路网编号
  129. stationId: '', // 收费站编号
  130. laneId: 0, // 车道号
  131. passTime: new Date(),// 通过时间(Date对象)
  132. vehicleType: 0, // 车型
  133. state: 0, // 状态(01-入口,02-出口)
  134. tollCollectorId: '',// 收费员工号
  135. classOrder: 0, // 班次
  136. // 克隆方法
  137. clone: function () {
  138. return StationPassInfo.create(
  139. this.roadNetId,
  140. this.stationId
  141. ).initPassData(this);
  142. },
  143. initPassData: function (data) {
  144. this.vehicleType = data.vehicleType || 0;
  145. this.state = data.state || 0;
  146. this.tollCollectorId = data.tollCollectorId || '';
  147. return this;
  148. }
  149. });
  150. return { create };
  151. })();
  152. // 车辆尺寸对象
  153. const VehicleDimension = (function () {
  154. // 工厂函数创建实例
  155. const create = (length, width, height) => ({
  156. length: 0, // 单位dm
  157. width: 0, // 单位dm
  158. height: 0, // 单位dm
  159. // 初始化方法
  160. init: (l, w, h) => {
  161. Object.assign(this, { length: l, width: w, height: h });
  162. return this;
  163. },
  164. // 克隆方法
  165. clone: function () {
  166. return VehicleDimension.create(
  167. this.length,
  168. this.width,
  169. this.height
  170. );
  171. }
  172. });
  173. return { create };
  174. })();
  175. // OBU车辆信息对象
  176. const ObuVehicleInfo = (function () {
  177. // 车辆类型枚举
  178. const VEHICLE_TYPES = {
  179. TYPE_1: 1, // 一型车
  180. TYPE_2: 2, // 二型车
  181. // ...其他类型
  182. };
  183. // 用户类型枚举
  184. const USER_TYPES = {
  185. NORMAL: 0, // 普通车
  186. COMMERCIAL: 6,// 商务车
  187. // ...其他类型
  188. };
  189. const create = (plateNo, plateColor, type) => ({
  190. plateNo: '', // 车牌号
  191. plateColor: '', // 车辆颜色(0-5)
  192. plateType: 0, // 车型(1-6)
  193. userType: USER_TYPES.NORMAL,
  194. plateSize: VehicleDimension.create(0, 0, 0),
  195. wheelNum: 0, // 车轮数
  196. axleNum: 0, // 车轴数
  197. wheelbase: 0, // 轴距(dm)
  198. loadAndSeatNum: 0, // 载重/座位数
  199. characteristic: '', // 特征
  200. engineNo: '', // 发动机编号
  201. // 初始化方法
  202. init: (params) => {
  203. Object.assign(this, params);
  204. this.plateSize.init(
  205. params.plateSize.length || 0,
  206. params.plateSize.width || 0,
  207. params.plateSize.height || 0
  208. );
  209. return this;
  210. },
  211. // 克隆方法
  212. clone: function () {
  213. return ObuVehicleInfo.create(
  214. this.plateNo,
  215. this.plateColor,
  216. this.plateType
  217. ).init(this);
  218. }
  219. });
  220. return { create };
  221. })();
  222. // 主对象定义
  223. const EtcVehicleInfo = (function () {
  224. const create = (obuid) => ({
  225. obuid: obuid || '', // OBUID
  226. // 状态标志
  227. isRemove: false, // 是否被拆卸 0-true-拆卸,1-false-未拆卸
  228. obuRemoveStatus:'00', // 是否被拆卸 00-拆卸,01-未拆卸
  229. iccExists: false, // IC卡存在状态 true-存在,false-无IC卡
  230. // 数据字段
  231. encryptedVehicleInfoFile: '', // 加密文件(16进制字符串)
  232. cardType: 0, // 业务系统卡类型
  233. transType: 0, // 交易类型
  234. cardRestMoney: 0, // 卡余额(单位:分)
  235. icCardNumber:'', // IC卡号(卡片网络编号 + CPU卡内部编号)
  236. // 嵌套对象
  237. obuIssuer: OBUIssuerInfo.create(''), // OBU发行商信息
  238. icIssuer: ICCIssuerInfo.create(''), // IC卡发行商信息
  239. lastStation: StationPassInfo.create('', ''), // 上次过站
  240. obuVehicle: ObuVehicleInfo.create('', '', 0), // OBU车辆信息
  241. vehicleInfoDe: '', // 解密明文
  242. vehicleClass: '', // 车型
  243. obuActivationStatus: "00", // 激活状态(00:未激活,01:激活)
  244. customDirectives:CustomDirectives.create(),
  245. bleDeviceInfo:BleDeviceInfo.create(),
  246. // 克隆方法
  247. clone: function () {
  248. return EtcVehicleInfo.create(this.obuid)
  249. .initAll(this);
  250. },
  251. initAll: function (source) {
  252. // 初始化所有嵌套对象
  253. this.obuIssuer.init(source.obuIssuer);
  254. this.icIssuer.init(source.icIssuer);
  255. this.lastStation.init(source.lastStation);
  256. this.obuVehicle.init(source.obuVehicle);
  257. this.customDirectives.init(source.customDirectives);
  258. this.bleDeviceInfo.init(source.bleDeviceInfo);
  259. return this;
  260. }
  261. });
  262. return { create };
  263. })();
  264. // 导出模块
  265. export default {
  266. EtcVehicleInfo,
  267. VehicleDimension,
  268. OBUIssuerInfo,
  269. ICCIssuerInfo,
  270. StationPassInfo,
  271. ObuVehicleInfo,
  272. CustomDirectives,
  273. BleDeviceInfo
  274. };