|
|
@@ -68,9 +68,9 @@ public class TransactionFlowPushFrame {
|
|
|
|
|
|
//log.info("sendTrans>订单上送>>>"+DataConversion.bytesToHexString(params));
|
|
|
String key = redisCache.getCacheObject(RedisConstant.KEYS+deviceConnectionMsg.getDeviceId());
|
|
|
- log.info("key>订单消息加密密钥>>>"+key);
|
|
|
+ log.info("key>{}订单消息加密密钥>>>"+key,deviceConnectionMsg.getDeviceId());
|
|
|
encrypt = Encrytion.aesEncrypt(params, key.getBytes());
|
|
|
- log.info("msg>订单加密消息>>>"+DataConversion.bytesToHexString(encrypt));
|
|
|
+ log.info("msg>{}订单加密消息>>>"+DataConversion.bytesToHexString(encrypt),deviceConnectionMsg.getDeviceId());
|
|
|
} catch (Exception e) {
|
|
|
log.info("pileCode:" + pileCode + " TransactionFlowPush params Exception");
|
|
|
e.printStackTrace();
|
|
|
@@ -98,12 +98,24 @@ public class TransactionFlowPushFrame {
|
|
|
return encrypt;
|
|
|
}
|
|
|
|
|
|
+ //todo 深谷5档位模型
|
|
|
+ byte[] params;
|
|
|
+ int frameType;
|
|
|
+ if(billingModel.getDeepValleyPrice().compareTo(BigDecimal.ZERO)>0 || billingModel.getDeepValleyServiceFee().compareTo(BigDecimal.ZERO)>0){
|
|
|
+ //5档计费
|
|
|
+ params = paramsSg(transOrder, pileCode, gunPort, createTime, endTime, billingModel, card, map,reason);
|
|
|
+ frameType = DeviceSendYkc.TRANSACTION_RECORDS_REQUEST_SG.getFrameType();
|
|
|
+ }else{
|
|
|
+ //4档计费
|
|
|
+ params = params16(transOrder, pileCode, gunPort, createTime, endTime, billingModel, card, map,reason);
|
|
|
+ frameType = DeviceSendYkc.TRANSACTION_RECORDS_REQUEST_16.getFrameType();
|
|
|
+ }
|
|
|
+
|
|
|
byte[] encrypt = new byte[0];
|
|
|
// 缓存上报的订单,上报失败30秒重试,
|
|
|
TransCheck transCheck = new TransCheck();
|
|
|
try {
|
|
|
//密钥变化这里存订单明文
|
|
|
- byte[] params = params(transOrder, pileCode, gunPort, createTime, endTime, billingModel, card, map,reason);
|
|
|
transCheck.setTrans(params);
|
|
|
transCheck.setCheck_time(0);
|
|
|
transCheck.setTime(System.currentTimeMillis());
|
|
|
@@ -114,14 +126,13 @@ public class TransactionFlowPushFrame {
|
|
|
return pileCode.getBytes();
|
|
|
}
|
|
|
if (encrypt.length > 0) {
|
|
|
- byte[] bytes = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST_16.getFrameType(), 0, encrypt, encrypt.length, deviceConnectionMsg.getIs18());
|
|
|
+ byte[] bytes = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(),frameType , 0, encrypt, encrypt.length, deviceConnectionMsg.getIs18());
|
|
|
try {
|
|
|
//outputStream..write(bytes)
|
|
|
//log.info("bytes>上送订单加密消息>>>"+DataConversion.bytesToHexString(bytes));
|
|
|
// log.info("bytes.length>上送订单加密length>>>"+bytes.length);
|
|
|
deviceConnectionMsg.getOutputStream().write(bytes);
|
|
|
deviceConnectionMsg.getOutputStream().flush();
|
|
|
-
|
|
|
//只有发送了才将校验订单写到redis里
|
|
|
redisCache.setCacheObject(RedisConstant.NO_RESPONSE_WAS_RECEIVED+pileCode,transCheck,6,TimeUnit.MINUTES);
|
|
|
} catch (IOException e) {
|
|
|
@@ -137,6 +148,499 @@ public class TransactionFlowPushFrame {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public byte[] paramsSg(byte[] transOrder, String pileCode, byte gunPort, long createTime, long endTime, BillingModel billingModel, byte[] card, Map<String, BigDecimal> map,int reason) {
|
|
|
+ //订单创建时间0和预留原因不存库
|
|
|
+ if (createTime > 0||reason!=TransConstant.START_FAIL) {
|
|
|
+ try {
|
|
|
+ //TODO:测试存订单
|
|
|
+ byte[] transOrders = new byte[8];
|
|
|
+ System.arraycopy(transOrder, 8, transOrders, 0, transOrders.length);
|
|
|
+ QueryWrapper<TransOrder> transOrderQueryWrapper = new QueryWrapper<>();
|
|
|
+ transOrderQueryWrapper.eq("trans", DataConversion.bytesToHexString(transOrders)).eq("pile_code", pileCode);
|
|
|
+ TransOrder transOrderServiceOne = transOrderService.getOne(transOrderQueryWrapper);
|
|
|
+ transOrderServiceOne.setStartTime(new Date(createTime));
|
|
|
+ transOrderServiceOne.setEndTime(new Date(endTime));
|
|
|
+ transOrderServiceOne.setSharpElec(map.get("elec1"));
|
|
|
+ transOrderServiceOne.setSharpMoney(map.get("money1"));
|
|
|
+ transOrderServiceOne.setPeakElec(map.get("elec2"));
|
|
|
+ transOrderServiceOne.setPeakMoney(map.get("money2"));
|
|
|
+ transOrderServiceOne.setFlatElec(map.get("elec3"));
|
|
|
+ transOrderServiceOne.setFlatMoney(map.get("money3"));
|
|
|
+ transOrderServiceOne.setValleyElec(map.get("elec4"));
|
|
|
+ transOrderServiceOne.setValleyMoney(map.get("money4"));
|
|
|
+ transOrderServiceOne.setElec(map.get("elec"));
|
|
|
+ transOrderServiceOne.setMoney(map.get("money"));
|
|
|
+ transOrderServiceOne.setReasonStopCharging(reason);
|
|
|
+ transOrderService.updateById(transOrderServiceOne);
|
|
|
+ //TODO:测试存订单
|
|
|
+ }catch(Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ redisCache.deleteObject(RedisConstant.DEVICE_CHARNGING_INFO + pileCode + gunPort);
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ byte[] msg = new byte[174];
|
|
|
+ //1.交易流水
|
|
|
+ byte[] trans = new byte[16];
|
|
|
+ System.arraycopy(transOrder, 0, trans, 0, transOrder.length);
|
|
|
+ System.arraycopy(trans, 0, msg, index, trans.length);
|
|
|
+ index += trans.length;
|
|
|
+
|
|
|
+ //2. 桩编码 BCD
|
|
|
+ byte[] pile_code = new byte[7];
|
|
|
+ System.arraycopy(DataConversion.bcdToBytes(pileCode, 7), 0, msg, index, pile_code.length);
|
|
|
+ index += pile_code.length;
|
|
|
+//3.枪号
|
|
|
+ byte[] guns = {gunPort};
|
|
|
+ System.arraycopy(guns, 0, msg, index, guns.length);
|
|
|
+ index += guns.length;
|
|
|
+
|
|
|
+ //4.开始时间
|
|
|
+ Date sdate = new Date(createTime);
|
|
|
+ byte[] startTime = new byte[7];
|
|
|
+ SimpleDateFormat se = new SimpleDateFormat("SS-ss-mm-HH-dd-MM-yy");
|
|
|
+ String sformat = se.format(sdate).substring(1);
|
|
|
+ startTime = CP56Time2a.timeCP56Time2a(sformat);
|
|
|
+ System.arraycopy(startTime, 0, msg, index, startTime.length);
|
|
|
+ index += startTime.length;
|
|
|
+
|
|
|
+ //5.结束时间
|
|
|
+ Date date = new Date(endTime);
|
|
|
+ byte[] time = new byte[7];
|
|
|
+ String format = se.format(date).substring(1);
|
|
|
+ time = CP56Time2a.timeCP56Time2a(format);
|
|
|
+ System.arraycopy(time, 0, msg, index, time.length);
|
|
|
+ index += time.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 10 尖单价 BIN 4 精确到小数点后五位(尖电费 + 尖 服务费,见费率帧)
|
|
|
+ byte[] bytes4 = DataConversion.bin4Tofiv((billingModel.getSharpPrice().add(billingModel.getSharpServiceFee())).setScale(5));
|
|
|
+ //bytes4 = Transaction.temp(bytes4);
|
|
|
+ System.arraycopy(bytes4, 0, msg, index, bytes4.length);
|
|
|
+ index += bytes4.length;
|
|
|
+
|
|
|
+ // 11 尖电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes5 = DataConversion.bin4Tofour(map.get("elec1").setScale(4));
|
|
|
+ //bytes5 = Transaction.temp(bytes5);
|
|
|
+ System.arraycopy(bytes5, 0, msg, index, bytes5.length);
|
|
|
+ index += bytes5.length;
|
|
|
+
|
|
|
+ // 12 计损尖电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes6 = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytes6 = Transaction.temp(bytes6);
|
|
|
+ System.arraycopy(bytes6, 0, msg, index, bytes6.length);
|
|
|
+ index += bytes6.length;
|
|
|
+
|
|
|
+ // 13 尖金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes7 = new byte[4];
|
|
|
+ bytes7 = DataConversion.bin4Tofour(map.get("money1").setScale(4));
|
|
|
+ System.arraycopy(bytes7, 0, msg, index, bytes7.length);
|
|
|
+ index += bytes7.length;
|
|
|
+
|
|
|
+ // 14 峰单价 BIN 4 精确到小数点后五位(峰电费 + 峰 服务费)
|
|
|
+ byte[] bytes8 = DataConversion.bin4Tofiv((billingModel.getPeakPrice().add(billingModel.getPeakServiceFee())).setScale(5));
|
|
|
+ // bytes8 = Transaction.temp(bytes8);
|
|
|
+ System.arraycopy(bytes8, 0, msg, index, bytes8.length);
|
|
|
+ index += bytes8.length;
|
|
|
+
|
|
|
+ // 15 峰电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes9 = DataConversion.bin4Tofour(map.get("elec2").setScale(4));
|
|
|
+ //bytes9 = Transaction.temp(bytes9);
|
|
|
+ System.arraycopy(bytes9, 0, msg, index, bytes9.length);
|
|
|
+ index += bytes9.length;
|
|
|
+
|
|
|
+ // 16 计损峰电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesa = DataConversion.bin4Tofour(zero);
|
|
|
+ //bytesa = Transaction.temp(bytesa);
|
|
|
+ System.arraycopy(bytesa, 0, msg, index, bytesa.length);
|
|
|
+ index += bytesa.length;
|
|
|
+
|
|
|
+ // 17 峰金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesb = DataConversion.bin4Tofour(map.get("money2").setScale(4));
|
|
|
+ // bytesb = Transaction.temp(bytesb);
|
|
|
+ System.arraycopy(bytesb, 0, msg, index, bytesb.length);
|
|
|
+ index += bytesb.length;
|
|
|
+
|
|
|
+ // 18 平单价 BIN 4 精确到小数点后五位(平电费 + 平 服务费)
|
|
|
+
|
|
|
+ byte[] bytesc = DataConversion.bin4Tofiv((billingModel.getFlatPrice().add(billingModel.getFlatServiceFee())).setScale(5));
|
|
|
+ //bytesc = Transaction.temp(bytesc);
|
|
|
+ System.arraycopy(bytesc, 0, msg, index, bytesc.length);
|
|
|
+ index += bytesc.length;
|
|
|
+
|
|
|
+ // 19 平电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesd = new byte[4];
|
|
|
+
|
|
|
+ bytesd = DataConversion.bin4Tofour(map.get("elec3").setScale(4));
|
|
|
+ // bytesd = Transaction.temp(bytesd);
|
|
|
+ System.arraycopy(bytesd, 0, msg, index, bytesd.length);
|
|
|
+ index += bytesd.length;
|
|
|
+
|
|
|
+ // 20 计损平电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytese = DataConversion.bin4Tofour(zero);
|
|
|
+ //bytese = Transaction.temp(bytese);
|
|
|
+ System.arraycopy(bytese, 0, msg, index, bytese.length);
|
|
|
+ index += bytese.length;
|
|
|
+
|
|
|
+ // 21 平金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesf = new byte[4];
|
|
|
+
|
|
|
+ bytesf = DataConversion.bin4Tofour(map.get("money3").setScale(4).setScale(4));
|
|
|
+ // bytesf = Transaction.temp(bytesf);
|
|
|
+ System.arraycopy(bytesf, 0, msg, index, bytesf.length);
|
|
|
+ index += bytesf.length;
|
|
|
+
|
|
|
+ // 22 谷单价 BIN 4 精确到小数点后五位(谷电费 + 谷 服务费)
|
|
|
+ byte[] bytesg = DataConversion.bin4Tofiv((billingModel.getValleyPrice().add(billingModel.getValleyServiceFee())).setScale(5));
|
|
|
+ // bytesg = Transaction.temp(bytesg);
|
|
|
+ System.arraycopy(bytesg, 0, msg, index, bytesg.length);
|
|
|
+ index += bytesg.length;
|
|
|
+
|
|
|
+ // 23 谷电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesh = new byte[4];
|
|
|
+ bytesh = DataConversion.bin4Tofour(map.get("elec4").setScale(4));//测试
|
|
|
+
|
|
|
+ //byte[] bytesh = DataConversion.four(transaction.getValleyElec());
|
|
|
+ System.arraycopy(bytesh, 0, msg, index, bytesh.length);
|
|
|
+ index += bytesh.length;
|
|
|
+
|
|
|
+ // 24 计损谷电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesi = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytesi = Transaction.temp(bytesi);
|
|
|
+ System.arraycopy(bytesi, 0, msg, index, bytesi.length);
|
|
|
+ index += bytesi.length;
|
|
|
+
|
|
|
+ // 25 谷金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesj = new byte[4];
|
|
|
+ bytesj = DataConversion.bin4Tofour(map.get("money4").setScale(4));
|
|
|
+ //byte[] bytesj = DataConversion.four(transaction.getValleyMoney());
|
|
|
+ System.arraycopy(bytesj, 0, msg, index, bytesj.length);
|
|
|
+ index += bytesj.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 22 深谷单价 BIN 4 精确到小数点后五位(深谷电费 + 深谷 服务费)
|
|
|
+ byte[] bytesdg = DataConversion.bin4Tofiv((billingModel.getDeepValleyPrice().add(billingModel.getDeepValleyServiceFee())).setScale(5));
|
|
|
+ System.arraycopy(bytesdg, 0, msg, index, bytesdg.length);
|
|
|
+ index += bytesdg.length;
|
|
|
+
|
|
|
+ // 23 深谷电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] byteshh = new byte[4];
|
|
|
+ byteshh = DataConversion.bin4Tofour(map.get("elec5").setScale(4));//测试
|
|
|
+ System.arraycopy(byteshh, 0, msg, index, byteshh.length);
|
|
|
+ index += byteshh.length;
|
|
|
+
|
|
|
+ // 24 计损谷电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytedsi = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytesi = Transaction.temp(bytesi);
|
|
|
+ System.arraycopy(bytedsi, 0, msg, index, bytedsi.length);
|
|
|
+ index += bytedsi.length;
|
|
|
+
|
|
|
+ // 25 深谷金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytedsj = new byte[4];
|
|
|
+ bytedsj = DataConversion.bin4Tofour(map.get("money5").setScale(4));
|
|
|
+ //byte[] bytesj = DataConversion.four(transaction.getValleyMoney());
|
|
|
+ System.arraycopy(bytedsj, 0, msg, index, bytedsj.length);
|
|
|
+ index += bytedsj.length;
|
|
|
+
|
|
|
+ // 26 电表总起值 BIN 5 精确到小数点后四位
|
|
|
+ byte[] bytesk = DataConversion.bin5Tofour(new BigDecimal("0.0001").setScale(4)); //测试
|
|
|
+ System.arraycopy(bytesk, 0, msg, index, bytesk.length);
|
|
|
+ index += bytesk.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 27 电表总止值 BIN 5 精确到小数点后四位
|
|
|
+ byte[] bytesl = new byte[5];
|
|
|
+ bytesl = DataConversion.bin5Tofour(new BigDecimal("0.0001").add(map.get("elec")).setScale(4)); //测试
|
|
|
+ System.arraycopy(bytesl, 0, msg, index, bytesl.length);
|
|
|
+ index += bytesl.length;
|
|
|
+
|
|
|
+ // 28 总电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesm = new byte[4];
|
|
|
+ bytesm = DataConversion.bin4Tofour(map.get("elec").setScale(4));//测试
|
|
|
+ System.arraycopy(bytesm, 0, msg, index, bytesm.length);
|
|
|
+ index += bytesm.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 29 计损总电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesn = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytesn = Transaction.temp(bytesn);
|
|
|
+ System.arraycopy(bytesn, 0, msg, index, bytesn.length);
|
|
|
+ index += bytesn.length;
|
|
|
+
|
|
|
+ // 30 消费金额 BIN 4 精确到小数点后四位,包含电费、服务费
|
|
|
+
|
|
|
+ byte[] byteso = DataConversion.bin4Tofour(map.get("money").setScale(4));
|
|
|
+ System.arraycopy(byteso, 0, msg, index, byteso.length);
|
|
|
+ index += byteso.length;
|
|
|
+
|
|
|
+// 31 电动汽车唯一标识 ASCII 17 VIN 码,此处 VIN 码和充电时 VIN 码不同,正序直接上传,无需补 0 和反序
|
|
|
+ byte[] bytesp = new byte[17];
|
|
|
+ bytesp = DataConversion.temp(bytesp);
|
|
|
+ System.arraycopy(bytesp, 0, msg, index, bytesp.length);
|
|
|
+ index += bytesp.length;
|
|
|
+
|
|
|
+ // 32 交易标识 BIN 1 0x01:app 启动 0x02:卡启动 0x04:离线卡启动 0x05:vin 码启动充电
|
|
|
+ byte[] bytesq = new byte[]{TransConstant.APP_START};
|
|
|
+ System.arraycopy(bytesq, 0, msg, index, bytesq.length);
|
|
|
+ index += bytesq.length;
|
|
|
+
|
|
|
+ // 33 交易日期、时间 BIN 7 CP56Time2a 格式
|
|
|
+ byte[] timej = new byte[7];
|
|
|
+// SimpleDateFormat ses = new SimpleDateFormat("yy-MM-dd-HH-mm-ss-SS");
|
|
|
+// String format1 = ses.format(new Date(System.currentTimeMillis()));
|
|
|
+// timej = CP56Time2a.timeCP56Time2a(format1.substring(0, format1.length() - 1));
|
|
|
+ System.arraycopy(time, 0, msg, index, timej.length);
|
|
|
+ index += timej.length;
|
|
|
+
|
|
|
+ // 34 停止原因 BIN 1 见附录 11.1
|
|
|
+ byte[] bytesr = new byte[]{(byte) reason};
|
|
|
+ log.info("订单>>>>停止原因>>>"+reason);
|
|
|
+ System.arraycopy(bytesr, 0, msg, index, bytesr.length);
|
|
|
+ index += bytesr.length;
|
|
|
+
|
|
|
+ // 35 物理卡号 BIN 码 8 不足 8 位补 0
|
|
|
+ byte[] bytess = new byte[8];
|
|
|
+ System.arraycopy(card, 0, bytess, 0, bytess.length);
|
|
|
+ System.arraycopy(bytess, 0, msg, index, bytess.length);
|
|
|
+ index += bytess.length;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ public byte[] params16(byte[] transOrder, String pileCode, byte gunPort, long createTime, long endTime, BillingModel billingModel, byte[] card, Map<String, BigDecimal> map,int reason) {
|
|
|
+ //订单创建时间0和预留原因不存库
|
|
|
+ if (createTime > 0||reason!=TransConstant.START_FAIL) {
|
|
|
+ try {
|
|
|
+ //TODO:测试存订单
|
|
|
+ byte[] transOrders = new byte[8];
|
|
|
+ System.arraycopy(transOrder, 8, transOrders, 0, transOrders.length);
|
|
|
+ QueryWrapper<TransOrder> transOrderQueryWrapper = new QueryWrapper<>();
|
|
|
+ transOrderQueryWrapper.eq("trans", DataConversion.bytesToHexString(transOrders)).eq("pile_code", pileCode);
|
|
|
+ TransOrder transOrderServiceOne = transOrderService.getOne(transOrderQueryWrapper);
|
|
|
+ transOrderServiceOne.setStartTime(new Date(createTime));
|
|
|
+ transOrderServiceOne.setEndTime(new Date(endTime));
|
|
|
+ transOrderServiceOne.setSharpElec(map.get("elec1"));
|
|
|
+ transOrderServiceOne.setSharpMoney(map.get("money1"));
|
|
|
+ transOrderServiceOne.setPeakElec(map.get("elec2"));
|
|
|
+ transOrderServiceOne.setPeakMoney(map.get("money2"));
|
|
|
+ transOrderServiceOne.setFlatElec(map.get("elec3"));
|
|
|
+ transOrderServiceOne.setFlatMoney(map.get("money3"));
|
|
|
+ transOrderServiceOne.setValleyElec(map.get("elec4"));
|
|
|
+ transOrderServiceOne.setValleyMoney(map.get("money4"));
|
|
|
+ transOrderServiceOne.setElec(map.get("elec"));
|
|
|
+ transOrderServiceOne.setMoney(map.get("money"));
|
|
|
+ transOrderServiceOne.setReasonStopCharging(reason);
|
|
|
+ transOrderService.updateById(transOrderServiceOne);
|
|
|
+ //TODO:测试存订单
|
|
|
+ }catch(Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ redisCache.deleteObject(RedisConstant.DEVICE_CHARNGING_INFO + pileCode + gunPort);
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ byte[] msg = new byte[158];
|
|
|
+ //1.交易流水
|
|
|
+ byte[] trans = new byte[16];
|
|
|
+ System.arraycopy(transOrder, 0, trans, 0, transOrder.length);
|
|
|
+ System.arraycopy(trans, 0, msg, index, trans.length);
|
|
|
+ index += trans.length;
|
|
|
+
|
|
|
+ //2. 桩编码 BCD
|
|
|
+ byte[] pile_code = new byte[7];
|
|
|
+ System.arraycopy(DataConversion.bcdToBytes(pileCode, 7), 0, msg, index, pile_code.length);
|
|
|
+ index += pile_code.length;
|
|
|
+//3.枪号
|
|
|
+ byte[] guns = {gunPort};
|
|
|
+ System.arraycopy(guns, 0, msg, index, guns.length);
|
|
|
+ index += guns.length;
|
|
|
+
|
|
|
+ //4.开始时间
|
|
|
+ Date sdate = new Date(createTime);
|
|
|
+ byte[] startTime = new byte[7];
|
|
|
+ SimpleDateFormat se = new SimpleDateFormat("SS-ss-mm-HH-dd-MM-yy");
|
|
|
+ String sformat = se.format(sdate).substring(1);
|
|
|
+ startTime = CP56Time2a.timeCP56Time2a(sformat);
|
|
|
+ System.arraycopy(startTime, 0, msg, index, startTime.length);
|
|
|
+ index += startTime.length;
|
|
|
+
|
|
|
+ //5.结束时间
|
|
|
+ Date date = new Date(endTime);
|
|
|
+ byte[] time = new byte[7];
|
|
|
+ String format = se.format(date).substring(1);
|
|
|
+ time = CP56Time2a.timeCP56Time2a(format);
|
|
|
+ System.arraycopy(time, 0, msg, index, time.length);
|
|
|
+ index += time.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 10 尖单价 BIN 4 精确到小数点后五位(尖电费 + 尖 服务费,见费率帧)
|
|
|
+ byte[] bytes4 = DataConversion.bin4Tofiv((billingModel.getSharpPrice().add(billingModel.getSharpServiceFee())).setScale(5));
|
|
|
+ //bytes4 = Transaction.temp(bytes4);
|
|
|
+ System.arraycopy(bytes4, 0, msg, index, bytes4.length);
|
|
|
+ index += bytes4.length;
|
|
|
+
|
|
|
+ // 11 尖电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes5 = DataConversion.bin4Tofour(map.get("elec1").setScale(4));
|
|
|
+ //bytes5 = Transaction.temp(bytes5);
|
|
|
+ System.arraycopy(bytes5, 0, msg, index, bytes5.length);
|
|
|
+ index += bytes5.length;
|
|
|
+
|
|
|
+ // 12 计损尖电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes6 = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytes6 = Transaction.temp(bytes6);
|
|
|
+ System.arraycopy(bytes6, 0, msg, index, bytes6.length);
|
|
|
+ index += bytes6.length;
|
|
|
+
|
|
|
+ // 13 尖金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes7 = new byte[4];
|
|
|
+ bytes7 = DataConversion.bin4Tofour(map.get("money1").setScale(4));
|
|
|
+ System.arraycopy(bytes7, 0, msg, index, bytes7.length);
|
|
|
+ index += bytes7.length;
|
|
|
+
|
|
|
+ // 14 峰单价 BIN 4 精确到小数点后五位(峰电费 + 峰 服务费)
|
|
|
+ byte[] bytes8 = DataConversion.bin4Tofiv((billingModel.getPeakPrice().add(billingModel.getPeakServiceFee())).setScale(5));
|
|
|
+ // bytes8 = Transaction.temp(bytes8);
|
|
|
+ System.arraycopy(bytes8, 0, msg, index, bytes8.length);
|
|
|
+ index += bytes8.length;
|
|
|
+
|
|
|
+ // 15 峰电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytes9 = DataConversion.bin4Tofour(map.get("elec2").setScale(4));
|
|
|
+ //bytes9 = Transaction.temp(bytes9);
|
|
|
+ System.arraycopy(bytes9, 0, msg, index, bytes9.length);
|
|
|
+ index += bytes9.length;
|
|
|
+
|
|
|
+ // 16 计损峰电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesa = DataConversion.bin4Tofour(zero);
|
|
|
+ //bytesa = Transaction.temp(bytesa);
|
|
|
+ System.arraycopy(bytesa, 0, msg, index, bytesa.length);
|
|
|
+ index += bytesa.length;
|
|
|
+
|
|
|
+ // 17 峰金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesb = DataConversion.bin4Tofour(map.get("money2").setScale(4));
|
|
|
+ // bytesb = Transaction.temp(bytesb);
|
|
|
+ System.arraycopy(bytesb, 0, msg, index, bytesb.length);
|
|
|
+ index += bytesb.length;
|
|
|
+
|
|
|
+ // 18 平单价 BIN 4 精确到小数点后五位(平电费 + 平 服务费)
|
|
|
+
|
|
|
+ byte[] bytesc = DataConversion.bin4Tofiv((billingModel.getFlatPrice().add(billingModel.getFlatServiceFee())).setScale(5));
|
|
|
+ //bytesc = Transaction.temp(bytesc);
|
|
|
+ System.arraycopy(bytesc, 0, msg, index, bytesc.length);
|
|
|
+ index += bytesc.length;
|
|
|
+
|
|
|
+ // 19 平电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesd = new byte[4];
|
|
|
+
|
|
|
+ bytesd = DataConversion.bin4Tofour(map.get("elec3").setScale(4));
|
|
|
+ // bytesd = Transaction.temp(bytesd);
|
|
|
+ System.arraycopy(bytesd, 0, msg, index, bytesd.length);
|
|
|
+ index += bytesd.length;
|
|
|
+
|
|
|
+ // 20 计损平电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytese = DataConversion.bin4Tofour(zero);
|
|
|
+ //bytese = Transaction.temp(bytese);
|
|
|
+ System.arraycopy(bytese, 0, msg, index, bytese.length);
|
|
|
+ index += bytese.length;
|
|
|
+
|
|
|
+ // 21 平金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesf = new byte[4];
|
|
|
+
|
|
|
+ bytesf = DataConversion.bin4Tofour(map.get("money3").setScale(4).setScale(4));
|
|
|
+ // bytesf = Transaction.temp(bytesf);
|
|
|
+ System.arraycopy(bytesf, 0, msg, index, bytesf.length);
|
|
|
+ index += bytesf.length;
|
|
|
+
|
|
|
+ // 22 谷单价 BIN 4 精确到小数点后五位(谷电费 + 谷 服务费)
|
|
|
+ byte[] bytesg = DataConversion.bin4Tofiv((billingModel.getValleyPrice().add(billingModel.getValleyServiceFee())).setScale(5));
|
|
|
+ // bytesg = Transaction.temp(bytesg);
|
|
|
+ System.arraycopy(bytesg, 0, msg, index, bytesg.length);
|
|
|
+ index += bytesg.length;
|
|
|
+
|
|
|
+ // 23 谷电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesh = new byte[4];
|
|
|
+ bytesh = DataConversion.bin4Tofour(map.get("elec4").setScale(4));//测试
|
|
|
+
|
|
|
+ //byte[] bytesh = DataConversion.four(transaction.getValleyElec());
|
|
|
+ System.arraycopy(bytesh, 0, msg, index, bytesh.length);
|
|
|
+ index += bytesh.length;
|
|
|
+
|
|
|
+ // 24 计损谷电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesi = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytesi = Transaction.temp(bytesi);
|
|
|
+ System.arraycopy(bytesi, 0, msg, index, bytesi.length);
|
|
|
+ index += bytesi.length;
|
|
|
+
|
|
|
+ // 25 谷金额 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesj = new byte[4];
|
|
|
+ bytesj = DataConversion.bin4Tofour(map.get("money4").setScale(4));
|
|
|
+ //byte[] bytesj = DataConversion.four(transaction.getValleyMoney());
|
|
|
+ System.arraycopy(bytesj, 0, msg, index, bytesj.length);
|
|
|
+ index += bytesj.length;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 26 电表总起值 BIN 5 精确到小数点后四位
|
|
|
+ byte[] bytesk = DataConversion.bin5Tofour(new BigDecimal("0.0001").setScale(4)); //测试
|
|
|
+ System.arraycopy(bytesk, 0, msg, index, bytesk.length);
|
|
|
+ index += bytesk.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 27 电表总止值 BIN 5 精确到小数点后四位
|
|
|
+ byte[] bytesl = new byte[5];
|
|
|
+ bytesl = DataConversion.bin5Tofour(new BigDecimal("0.0001").add(map.get("elec")).setScale(4)); //测试
|
|
|
+ System.arraycopy(bytesl, 0, msg, index, bytesl.length);
|
|
|
+ index += bytesl.length;
|
|
|
+
|
|
|
+ // 28 总电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesm = new byte[4];
|
|
|
+ bytesm = DataConversion.bin4Tofour(map.get("elec").setScale(4));//测试
|
|
|
+ System.arraycopy(bytesm, 0, msg, index, bytesm.length);
|
|
|
+ index += bytesm.length;
|
|
|
+
|
|
|
+
|
|
|
+ // 29 计损总电量 BIN 4 精确到小数点后四位
|
|
|
+ byte[] bytesn = DataConversion.bin4Tofour(zero);
|
|
|
+ // bytesn = Transaction.temp(bytesn);
|
|
|
+ System.arraycopy(bytesn, 0, msg, index, bytesn.length);
|
|
|
+ index += bytesn.length;
|
|
|
+
|
|
|
+ // 30 消费金额 BIN 4 精确到小数点后四位,包含电费、服务费
|
|
|
+
|
|
|
+ byte[] byteso = DataConversion.bin4Tofour(map.get("money").setScale(4));
|
|
|
+ System.arraycopy(byteso, 0, msg, index, byteso.length);
|
|
|
+ index += byteso.length;
|
|
|
+
|
|
|
+// 31 电动汽车唯一标识 ASCII 17 VIN 码,此处 VIN 码和充电时 VIN 码不同,正序直接上传,无需补 0 和反序
|
|
|
+ byte[] bytesp = new byte[17];
|
|
|
+ bytesp = DataConversion.temp(bytesp);
|
|
|
+ System.arraycopy(bytesp, 0, msg, index, bytesp.length);
|
|
|
+ index += bytesp.length;
|
|
|
+
|
|
|
+ // 32 交易标识 BIN 1 0x01:app 启动 0x02:卡启动 0x04:离线卡启动 0x05:vin 码启动充电
|
|
|
+ byte[] bytesq = new byte[]{TransConstant.APP_START};
|
|
|
+ System.arraycopy(bytesq, 0, msg, index, bytesq.length);
|
|
|
+ index += bytesq.length;
|
|
|
+
|
|
|
+ // 33 交易日期、时间 BIN 7 CP56Time2a 格式
|
|
|
+ byte[] timej = new byte[7];
|
|
|
+// SimpleDateFormat ses = new SimpleDateFormat("yy-MM-dd-HH-mm-ss-SS");
|
|
|
+// String format1 = ses.format(new Date(System.currentTimeMillis()));
|
|
|
+// timej = CP56Time2a.timeCP56Time2a(format1.substring(0, format1.length() - 1));
|
|
|
+ System.arraycopy(time, 0, msg, index, timej.length);
|
|
|
+ index += timej.length;
|
|
|
+
|
|
|
+ // 34 停止原因 BIN 1 见附录 11.1
|
|
|
+ byte[] bytesr = new byte[]{(byte) reason};
|
|
|
+ log.info("订单>>>>停止原因>>>"+reason);
|
|
|
+ System.arraycopy(bytesr, 0, msg, index, bytesr.length);
|
|
|
+ index += bytesr.length;
|
|
|
+
|
|
|
+ // 35 物理卡号 BIN 码 8 不足 8 位补 0
|
|
|
+ byte[] bytess = new byte[8];
|
|
|
+ System.arraycopy(card, 0, bytess, 0, bytess.length);
|
|
|
+ System.arraycopy(bytess, 0, msg, index, bytess.length);
|
|
|
+ index += bytess.length;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
public byte[] params(byte[] transOrder, String pileCode, byte gunPort, long createTime, long endTime, BillingModel billingModel, byte[] card, Map<String, BigDecimal> map,int reason) {
|
|
|
//订单创建时间0和预留原因不存库
|
|
|
if (createTime > 0||reason!=TransConstant.START_FAIL) {
|