| | |
| | | OnlineMessage onlineMessage = JSON.parseObject(content.toJSONString(),OnlineMessage.class); |
| | | chargingMessage.setOnlineMessage(onlineMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 响应硬件 |
| | | // 业务处理 登录认证应答 |
| | | OnlineReply onlineReply = new OnlineReply(); |
| | | onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code()); |
| | | onlineReply.setOnline_result(0); |
| | | String result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply)); |
| | | log.info("充电桩登录认证-返回结果:{}",result); |
| | | // 响应硬件 对时设置应答 |
| | | TimingSettingReply timingSettingReplyOnline = new TimingSettingReply(); |
| | | timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code()); |
| | | timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); |
| | | iotMessageProduce.sendMessage(timingSettingReplyOnline.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline)); |
| | | } |
| | | }).start(); |
| | | // 响应硬件 |
| | | // 业务处理 登录认证应答 |
| | | OnlineReply onlineReply = new OnlineReply(); |
| | | onlineReply.setCharging_pile_code(onlineMessage.getCharging_pile_code()); |
| | | onlineReply.setOnline_result(0); |
| | | result = iotMessageProduce.sendMessage(onlineReply.getCharging_pile_code(), ServiceIdMenu.ONLINE_REPLY.getKey(), messageUtil.onlineReply(onlineReply)); |
| | | log.info("充电桩登录认证-返回结果:{}",result); |
| | | // 响应硬件 对时设置应答 |
| | | TimingSettingReply timingSettingReplyOnline = new TimingSettingReply(); |
| | | timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code()); |
| | | timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); |
| | | iotMessageProduce.sendMessage(timingSettingReplyOnline.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.PING: |
| | |
| | | chargingMessage.setPingMessage(pingMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Pong pong = new Pong(); |
| | | pong.setCharging_pile_code(pingMessage.getCharging_pile_code()); |
| | | pong.setCharging_gun_code(pingMessage.getCharging_gun_code()); |
| | | pong.setCharging_gun_status(0); |
| | | iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong)); |
| | | } |
| | | }).start(); |
| | | Pong pong = new Pong(); |
| | | pong.setCharging_pile_code(pingMessage.getCharging_pile_code()); |
| | | pong.setCharging_gun_code(pingMessage.getCharging_gun_code()); |
| | | pong.setCharging_gun_status(0); |
| | | iotMessageProduce.sendMessage(pong.getCharging_pile_code(), ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.END_CHARGE: |
| | |
| | | chargingMessage.setBillingModeVerifyMessage(billingModeVerifyMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | BillingModeVerifyReply billingModeVerifyReply = new BillingModeVerifyReply(); |
| | | if(billingModeVerifyMessage.getBilling_model_code().equals("0")){ |
| | | // 首次 |
| | | billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); |
| | | billingModeVerifyReply.setBilling_model_code("0"); |
| | | billingModeVerifyReply.setBilling_model_result(1); |
| | | }else { |
| | | // 查询桩使用的模版 |
| | | CheckChargingStrategyDTO dto = new CheckChargingStrategyDTO(); |
| | | dto.setCode(billingModeVerifyMessage.getCharging_pile_code()); |
| | | dto.setStrategyDetailId(Integer.valueOf(billingModeVerifyMessage.getBilling_model_code())); |
| | | Boolean check = accountingStrategyDetailClient.checkChargingStrategy(dto).getData(); |
| | | // 校验计费模版是否准确 |
| | | billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); |
| | | billingModeVerifyReply.setBilling_model_code(billingModeVerifyMessage.getBilling_model_code()); |
| | | if(check){ |
| | | billingModeVerifyReply.setBilling_model_result(0); |
| | | }else { |
| | | billingModeVerifyReply.setBilling_model_result(1); |
| | | } |
| | | } |
| | | iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply)); |
| | | BillingModeVerifyReply billingModeVerifyReply = new BillingModeVerifyReply(); |
| | | if(billingModeVerifyMessage.getBilling_model_code().equals("0")){ |
| | | // 首次 |
| | | billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); |
| | | billingModeVerifyReply.setBilling_model_code("0"); |
| | | billingModeVerifyReply.setBilling_model_result(1); |
| | | }else { |
| | | // 查询桩使用的模版 |
| | | CheckChargingStrategyDTO dto = new CheckChargingStrategyDTO(); |
| | | dto.setCode(billingModeVerifyMessage.getCharging_pile_code()); |
| | | dto.setStrategyDetailId(Integer.valueOf(billingModeVerifyMessage.getBilling_model_code())); |
| | | Boolean check = accountingStrategyDetailClient.checkChargingStrategy(dto).getData(); |
| | | // 校验计费模版是否准确 |
| | | billingModeVerifyReply.setCharging_pile_code(billingModeVerifyMessage.getCharging_pile_code()); |
| | | billingModeVerifyReply.setBilling_model_code(billingModeVerifyMessage.getBilling_model_code()); |
| | | if(check){ |
| | | billingModeVerifyReply.setBilling_model_result(0); |
| | | }else { |
| | | billingModeVerifyReply.setBilling_model_result(1); |
| | | } |
| | | }).start(); |
| | | } |
| | | iotMessageProduce.sendMessage(billingModeVerifyReply.getCharging_pile_code(), ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.ACQUISITION_BILLING_MODE: |
| | |
| | | chargingMessage.setAcquisitionBillingModeMessage(acquisitionBillingModeMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 计费模型请求应答 1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getDetailListByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); |
| | | Map<Integer, TAccountingStrategyDetail> strategyPrice = StrategyUtil.getStrategyPrice(accountingStrategyDetails); |
| | | // 价格设置 |
| | | AcquisitionBillingModeReply acquisitionBillingModeReply = new AcquisitionBillingModeReply(); |
| | | StrategyUtil.setStrategyPrice(strategyPrice,acquisitionBillingModeReply); |
| | | // 时段设置 |
| | | StrategyUtil.setTime(accountingStrategyDetails,acquisitionBillingModeReply); |
| | | TAccountingStrategyDetail accountingStrategyDetail = accountingStrategyDetailClient.getDetailByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); |
| | | acquisitionBillingModeReply.setBilling_model_code(accountingStrategyDetail.getId().toString()); |
| | | acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code()); |
| | | acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO); |
| | | iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply)); |
| | | } |
| | | }).start(); |
| | | List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getDetailListByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); |
| | | Map<Integer, TAccountingStrategyDetail> strategyPrice = StrategyUtil.getStrategyPrice(accountingStrategyDetails); |
| | | // 价格设置 |
| | | AcquisitionBillingModeReply acquisitionBillingModeReply = new AcquisitionBillingModeReply(); |
| | | StrategyUtil.setStrategyPrice(strategyPrice,acquisitionBillingModeReply); |
| | | // 时段设置 |
| | | StrategyUtil.setTime(accountingStrategyDetails,acquisitionBillingModeReply); |
| | | TAccountingStrategyDetail accountingStrategyDetail = accountingStrategyDetailClient.getDetailByCode(acquisitionBillingModeMessage.getCharging_pile_code()).getData(); |
| | | acquisitionBillingModeReply.setBilling_model_code(accountingStrategyDetail.getId().toString()); |
| | | acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code()); |
| | | acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO); |
| | | iotMessageProduce.sendMessage(acquisitionBillingModeReply.getCharging_pile_code(), ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA: |
| | |
| | | chargingMessage.setChargingPileStartsChargingMessage(chargingPileStartsChargingMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | PlatformConfirmationCharging platformConfirmationCharging = new PlatformConfirmationCharging(); |
| | | platformConfirmationCharging.setCharging_pile_code(chargingPileStartsChargingMessage.getCharging_pile_code()); |
| | | platformConfirmationCharging.setCharging_gun_code(chargingPileStartsChargingMessage.getCharging_gun_code()); |
| | | platformConfirmationCharging.setCard_number(chargingPileStartsChargingMessage.getAccount()); |
| | | platformConfirmationCharging.setAccount_balance(BigDecimal.ZERO); |
| | | platformConfirmationCharging.setAuthentication(1); |
| | | // TODO 若是失败,给出失败原因 |
| | | iotMessageProduce.sendMessage(platformConfirmationCharging.getCharging_pile_code(), ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging)); |
| | | } |
| | | }).start(); |
| | | PlatformConfirmationCharging platformConfirmationCharging = new PlatformConfirmationCharging(); |
| | | platformConfirmationCharging.setCharging_pile_code(chargingPileStartsChargingMessage.getCharging_pile_code()); |
| | | platformConfirmationCharging.setCharging_gun_code(chargingPileStartsChargingMessage.getCharging_gun_code()); |
| | | platformConfirmationCharging.setCard_number(chargingPileStartsChargingMessage.getAccount()); |
| | | platformConfirmationCharging.setAccount_balance(BigDecimal.ZERO); |
| | | platformConfirmationCharging.setAuthentication(1); |
| | | // TODO 若是失败,给出失败原因 |
| | | iotMessageProduce.sendMessage(platformConfirmationCharging.getCharging_pile_code(), ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.PLATFORM_START_CHARGING_REPLY: |
| | |
| | | chargingMessage.setTransactionRecordMessage(transactionRecordMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord(); |
| | | confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number()); |
| | | confirmTransactionRecord.setConfirm_result(0); |
| | | iotMessageProduce.sendMessage(transactionRecordMessage.getCharging_pile_code(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord)); |
| | | } |
| | | }).start(); |
| | | ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord(); |
| | | confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number()); |
| | | confirmTransactionRecord.setConfirm_result(0); |
| | | iotMessageProduce.sendMessage(transactionRecordMessage.getCharging_pile_code(), ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.UPDATE_BALANCE_REPLY: |
| | |
| | | chargingMessage.setTimingSettingMessage(timingSettingMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | | // 响应硬件 对时设置应答 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | TimingSettingReply timingSettingReply = new TimingSettingReply(); |
| | | timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code()); |
| | | timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); |
| | | iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply)); |
| | | } |
| | | }).start(); |
| | | TimingSettingReply timingSettingReply = new TimingSettingReply(); |
| | | timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code()); |
| | | timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date())); |
| | | iotMessageProduce.sendMessage(timingSettingReply.getCharging_pile_code(), ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply)); |
| | | // sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | break; |
| | | case SendTagConstant.SETUP_BILLING_MODEL_REPLY: |