選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

wjDataAnalysis.js 9.7KB

1
  1. "use strict";var _wjUtils=require("./wjUtils.js"),_wjUtils2=_interopRequireDefault(_wjUtils);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function analysisCardInfo(e){var t,r,a,s,i,l,c,n,o=_wjUtils2.default.hexStr2byteArray(e),d={},y=o.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(55==y?(e=o.slice(2,10),y=o.slice(10,11),o.slice(11,12),t=o.slice(12,14),r=o.slice(14,22),a=o.slice(22,26),o.slice(26,30),s=o.slice(30,42),i=o.slice(42,43),l=o.slice(43,44),c=o.slice(44,45),o=o.slice(49,53),n=parseInt((255&o[0])<<24),n=(n=(n+=parseInt((255&o[1])<<16))+parseInt((255&o[2])<<8))+parseInt(255&o[3]),_wjUtils2.default.showLog("cardIssuerID:",_wjUtils2.default.byteArray2hexStr(e),"bindedPlate",_wjUtils2.default.byteArray2hexStr(s),"balance:",n),d.serviceCode=0,d.serviceInfo="获取卡片信息成功",d.serviceData={},d.serviceData.cardIssuerID=_wjUtils2.default.byteArray2hexStr(e),d.serviceData.cardType=_wjUtils2.default.byteArray2hexStr(y),d.serviceData.roadswebID=_wjUtils2.default.byteArray2hexStr(t),d.serviceData.cardNo=_wjUtils2.default.byteArray2hexStr(r),d.serviceData.SignedDate=_wjUtils2.default.byteArray2hexStr(a),d.serviceData.bindedPlate=_wjUtils2.default.byteArray2hexStr(s),d.serviceData.userType=_wjUtils2.default.byteArray2hexStr(i),d.serviceData.vehColor=_wjUtils2.default.byteArray2hexStr(l),d.serviceData.vehType=_wjUtils2.default.byteArray2hexStr(c),d.serviceData.intbalance=n):(d.serviceCode=-3,d.serviceInfo="获取卡片信息失败,信息长度有误"),d)}function analysisCardOwnerRecord(e){var t,r,a=_wjUtils2.default.hexStr2byteArray(e),s={},i=a.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(59==i?(e=a.slice(2,3),i=a.slice(3,4),t=a.slice(4,24),r=a.slice(24,56),a=a.slice(56,57),_wjUtils2.default.showLog("ownerName:",_wjUtils2.default.byteArray2hexStr(t),"ownerLicenseNumber:",_wjUtils2.default.byteArray2hexStr(r),"ownerLicenseType:",a),s.serviceCode=0,s.serviceInfo="获取持卡人信息成功",s.serviceData={},s.serviceData.ownerId=_wjUtils2.default.byteArray2hexStr(e),s.serviceData.staffId=_wjUtils2.default.byteArray2hexStr(i),s.serviceData.ownerName=_wjUtils2.default.byteArray2hexStr(t),s.serviceData.ownerLicenseNumber=_wjUtils2.default.byteArray2hexStr(r),s.serviceData.ownerLicenseType=_wjUtils2.default.byteArray2hexStr(a)):(s.serviceCode=-3,s.serviceInfo="获取持卡人信息失败,信息长度有误"),s)}function analysisCardTransactionRecord(e){var t=_wjUtils2.default.hexStr2byteArray(e),r={},a=t.byteLength,s=0;if(4<=a){for(r.serviceCode=0,r.serviceInfo="获取交易记录信息成功",r.serviceData={},r.serviceData.CardTransactionRecordData=[];s<a;){var i=t[s++],l=t[s]-1;if(_wjUtils2.default.showLog("WJ9000校验第"+i+"条:",t[s+l],t[s+l+1]),144!=t[s+l]||0!=t[s+l+1])break;i={};s++,i.onlineSn=t.slice(s,s+2),s+=2,i.overdrawLimit=t.slice(s,s+3),s+=3,i.transAmount=t.slice(s,s+4),s+=4,i.transType=t.slice(s,s+1),s+=1,i.terminalNo=t.slice(s,s+6),s+=6,i.transDate=t.slice(s,s+4),s+=4,i.transTime=t.slice(s,s+3),s=s+3+2,r.serviceData.CardTransactionRecordData.push(i),console.log("cardTransactionRecordBean:",i,s)}console.log("交易记录:",r)}else r.serviceCode=-3,r.serviceInfo="获取交易记录失败,信息长度有误";return r}function analysisgetCardConsumeRecord(e){var t=_wjUtils2.default.hexStr2byteArray(e),r={},a=t.byteLength,s=0;if(4<=a){for(r.serviceCode=0,r.serviceInfo="获取过站信息成功",r.serviceData={},r.serviceData.CardConsumeRecordData=[];s<a;){var i=t[s++],l=t[s]-1;if(_wjUtils2.default.showLog("WJ9000校验第"+i+"条:",t[s+l],t[s+l+1]),144!=t[s+l]||0!=t[s+l+1])break;i={};s++,i.tollRoadNetworkId=t.slice(2,4),s+=2,i.tollStationId=t.slice(4,6),s+=2,i.tollLaneId=t.slice(6,7),s+=1,i.timeUnix=t.slice(7,11),s+=4,i.vehicleModel=t.slice(11,12),s+=1,i.passStatus=t.slice(12,13),s+=1,i.reserve1=t.slice(13,22),s+=9,i.staffNo=t.slice(22,25),s+=3,i.mtcSequenceNo=t.slice(25,26),s+=1,i.staffNo=t.slice(26,38),s+=12,i.mtcSequenceNo=t.slice(38,42),s=s+4+2,r.serviceData.CardConsumeRecordData.push(i),console.log("cardConsumeRecordBean",i,s)}console.log("过站信息:",r)}else r.serviceCode=-3,r.serviceInfo="获取过站信息失败,信息长度有误";return r}function analysisInitInfo(e){var t,r,a,s,i=_wjUtils2.default.hexStr2byteArray(e),l={},c=i.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(20==c?(e=i.slice(2,6),c=i.slice(6,8),t=i.slice(8,9),r=i.slice(9,10),a=i.slice(10,14),i=i.slice(14,18),s=parseInt((255&e[0])<<24),s=(s=(s+=parseInt((255&e[1])<<16))+parseInt((255&e[2])<<8))+parseInt(255&e[3]),_wjUtils2.default.showLog("intbalance:",s,"pseudoRand:",_wjUtils2.default.byteArray2hexStr(a),"Mac1:",_wjUtils2.default.byteArray2hexStr(i),"CardSeq:",_wjUtils2.default.byteArray2hexStr(c)),l.serviceCode=0,l.serviceInfo="解析圈存初始化成功",l.serviceData={},l.serviceData.intbalance=s,l.serviceData.CardSeq=_wjUtils2.default.byteArray2hexStr(c),l.serviceData.keyVersion=_wjUtils2.default.byteArray2hexStr(t),l.serviceData.algTag=_wjUtils2.default.byteArray2hexStr(r),l.serviceData.pseudoRand=_wjUtils2.default.byteArray2hexStr(a),l.serviceData.Mac1=_wjUtils2.default.byteArray2hexStr(i)):(l.serviceCode=-3,l.serviceInfo="解析圈存初始化失败,信息长度有误"),l)}function analysisLoadCreadit(e){var t=_wjUtils2.default.hexStr2byteArray(e),r={},a=t.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(8==a?(e=t.slice(2,6),_wjUtils2.default.showLog("TAG",_wjUtils2.default.byteArray2hexStr(e)),r.serviceCode=0,r.serviceInfo="圈存成功",r.serviceData={},r.serviceData.TAG=_wjUtils2.default.byteArray2hexStr(e)):(r.serviceCode=-3,r.serviceInfo="圈存解析失败,长度有误"),r)}function analysisgetObuSysInfo(e){var t,r,a,s,i=_wjUtils2.default.hexStr2byteArray(e),l={},c=i.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(31==c?(e=i.slice(2,10),c=i.slice(10,11),t=i.slice(11,12),r=i.slice(12,20),a=i.slice(20,24),s=i.slice(24,28),i=i.slice(28,29),_wjUtils2.default.showLog("contractProvider",_wjUtils2.default.byteArray2hexStr(e),"contractSerialNumber",_wjUtils2.default.byteArray2hexStr(r),"issueFlag",_wjUtils2.default.byteArray2hexStr(i)),l.serviceCode=0,l.serviceInfo="获取OBU系统成功",l.serviceData={},l.serviceData.contractProvider=_wjUtils2.default.byteArray2hexStr(e),l.serviceData.contractType=_wjUtils2.default.byteArray2hexStr(c),l.serviceData.contractVersion=_wjUtils2.default.byteArray2hexStr(t),l.serviceData.contractSerialNumber=_wjUtils2.default.byteArray2hexStr(r),l.serviceData.contractSignedDate=_wjUtils2.default.byteArray2hexStr(a),l.serviceData.contractExpiredDate=_wjUtils2.default.byteArray2hexStr(s),l.serviceData.issueFlag=_wjUtils2.default.byteArray2hexStr(i)):(l.serviceCode=-1,l.serviceInfo="OBU系统信息解析失败,长度有误"),l)}function analysisGetRand(e){var t=_wjUtils2.default.hexStr2byteArray(e),r={},a=t.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(8==a?(e=t.slice(2,6),_wjUtils2.default.showLog("rand",_wjUtils2.default.byteArray2hexStr(e)),r.serviceCode=0,r.serviceInfo="获取随机数成功",r.serviceData={},r.serviceData.rand=_wjUtils2.default.byteArray2hexStr(e)):(r.serviceCode=-1,r.serviceInfo="获取随机数失败,长度有误"),r)}function analysisVehCipherInfo(e){var t=_wjUtils2.default.hexStr2byteArray(e),r={},a=t.byteLength,e=_analysisIs9000(e);return 0!=e.serviceCode?e:(3<=a?(e=t.slice(2,a-2),_wjUtils2.default.showLog("cipherVehInfo",_wjUtils2.default.byteArray2hexStr(e)),r.serviceCode=0,r.serviceInfo="获取密文车辆信息成功",r.serviceData={},r.serviceData.cipherVehInfo=_wjUtils2.default.byteArray2hexStr(e)):(r.serviceCode=-1,r.serviceInfo="获取密文车辆信息失败,长度有误"),r)}function _analysisIs9000(e){var t=_wjUtils2.default.hexStr2byteArray(e),r={},a=0,s=t.byteLength;if(4<=s)for(;a<s;){var i=t[a++];if(a+=t[a]-1,_wjUtils2.default.showLog("WJ9000校验第"+i+"条:",t[a],t[a+1]),144!=t[a]||0!=t[a+1]){r.serviceCode=-1,r.serviceInfo="WJ第"+i+"包APDU非9000";break}a+=2,r.serviceCode=0,r.serviceInfo="9000认证成功"}else r.serviceCode=-2,r.serviceInfo="9000认证失败,长度有误";return r}function analysisDeviceInfo(e){var t,r,a,s,i,l=_wjUtils2.default.hexStr2byteArray(e),c={},n=l.byteLength,o=l[0];switch(_wjUtils2.default.showLog(e),o){case 2:return 18==n?(a=l.slice(2),_wjUtils2.default.showLog("deviceSN:",_wjUtils2.default.byteArray2hexStr(a)),c.serviceCode=0,c.serviceInfo="获取设备信息成功",c.serviceData={},c.serviceData.deviceSN=_wjUtils2.default.byteArray2hexStr(a)):(c.serviceCode=-1,c.serviceInfo="获取设备信息失败,信息长度有误"),c;case 204:return 17==n?(t=l.slice(1,3),r=l.slice(3,4),a=l.slice(4,12),s=l.slice(12,16),i=l.slice(16),_wjUtils2.default.showLog("deviceSN:",_wjUtils2.default.byteArray2hexStr(a),"bleMac:",_wjUtils2.default.byteArray2hexStr(s),"flag:",_wjUtils2.default.byteArray2hexStr(i)),c.serviceCode=0,c.serviceInfo="获取设备信息成功",c.serviceData={},c.serviceData.verId=_wjUtils2.default.byteArray2hexStr(t),c.serviceData.battery=_wjUtils2.default.byteArray2hexStr(r),c.serviceData.deviceSN=_wjUtils2.default.byteArray2hexStr(a),c.serviceData.bleMac=_wjUtils2.default.byteArray2hexStr(s),c.serviceData.flag=i):(c.serviceCode=-1,c.serviceInfo="获取设备信息失败,信息长度有误"),c;default:return c.serviceCode=-2,c.serviceInfo="获取设备信息失败,指令类型有误",_wjUtils2.default.showError("WJ获取设备信息失败:","指令类型有误"),c}}module.exports={analysisCardInfo:analysisCardInfo,analysisDeviceInfo:analysisDeviceInfo,analysisInitInfo:analysisInitInfo,analysisLoadCreadit:analysisLoadCreadit,analysisgetObuSysInfo:analysisgetObuSysInfo,analysisGetRand:analysisGetRand,_analysisIs9000:_analysisIs9000,analysisVehCipherInfo:analysisVehCipherInfo,analysisCardOwnerRecord:analysisCardOwnerRecord,analysisCardTransactionRecord:analysisCardTransactionRecord,analysisgetCardConsumeRecord:analysisgetCardConsumeRecord};