| | |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | |
| | | pingService.save(ping); |
| | | //存储缓存中,5分钟有效 |
| | | redisTemplate.opsForValue().set("ping:" + ping.getCharging_pile_code() + ping.getCharging_gun_code(), ping, 5, TimeUnit.MINUTES); |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | UpdateChargingPileStatusVo vo1 = new UpdateChargingPileStatusVo(); |
| | | vo1.setGun_code(pingMessage.getCharging_gun_code()); |
| | | vo1.setPile_code(pingMessage.getCharging_pile_code()); |
| | | vo1.setStatus(pingMessage.getCharging_gun_status()); |
| | | chargingPileClient.updateChargingPileStatus(vo1); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | try { |
| | | tcecPushUtil.pushSuperviseNotificationStationStatus(chargingGunClient.getChargingGunByFullNumber(pingMessage.getCharging_pile_code()+pingMessage.getCharging_gun_code()).getData()); |
| | | }catch (Exception e){ |
| | |
| | | System.out.println("设备状态推送监管平台失败:"+e.getMessage()); |
| | | } |
| | | } |
| | | }).start(); |
| | | }); |
| | | break; |
| | | case SendTagConstant.END_CHARGE: |
| | | EndChargeMessage endChargeMessage = message.getEndChargeMessage(); |
| | |
| | | EndCharge endCharge = new EndCharge(); |
| | | BeanUtils.copyProperties(endChargeMessage,endCharge); |
| | | endChargeService.create(endCharge); |
| | | // 业务处理 |
| | | chargingOrderClient.endCharge(endCharge.getTransaction_serial_number()); |
| | | // 监管平台 |
| | | // 查询订单信息 |
| | | new Thread(new Runnable() { |
| | | ThreadPoolExecutor threadPoolExecutor1 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor1.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | chargingOrderClient.endCharge(endCharge.getTransaction_serial_number()); |
| | | try { |
| | | TChargingOrder chargingOrder = chargingOrderClient.getOrderByCode(endCharge.getTransaction_serial_number()).getData(); |
| | | tcecPushUtil.pushSuperviseNotificationChargeOrderInfo(chargingOrder); |
| | |
| | | System.out.println("充电结束推送监管平台失败:"+e.getMessage()); |
| | | } |
| | | } |
| | | }).start(); |
| | | }); |
| | | break; |
| | | case SendTagConstant.ERROR_MESSAGE: |
| | | ErrorMessageMessage errorMessageMessage1 = message.getErrorMessageMessage(); |
| | |
| | | if(i == 0){ |
| | | log.error("数据存储mongo失败"); |
| | | } |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor2 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor2.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | UploadRealTimeMonitoringDataQuery query = new UploadRealTimeMonitoringDataQuery(); |
| | | BeanUtils.copyProperties(uploadRealTimeMonitoringData, query); |
| | | chargingOrderClient.chargeMonitoring(query); |
| | | chargingOrder.setEndSoc(uploadRealTimeMonitoringDataMessage.getSoc()+""); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | tcecPushUtil.pushSuperviseNotificationEquipChargeStatus(chargingOrder); |
| | | } |
| | | }).start(); |
| | | |
| | | }); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | BmsAbort bmsAbort = new BmsAbort(); |
| | | BeanUtils.copyProperties(bmsAbortMessage,bmsAbort); |
| | | bmsAbortService.create(bmsAbort); |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor3 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor3.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | chargingOrderClient.excelEndCharge(bmsAbort.getTransaction_serial_number()); |
| | | } |
| | | }); |
| | | break; |
| | | case SendTagConstant.MOTOR_ABORT: |
| | | MotorAbortMessage motorAbortMessage = message.getMotorAbortMessage(); |
| | |
| | | MotorAbort motorAbort = new MotorAbort(); |
| | | BeanUtils.copyProperties(motorAbortMessage,motorAbort); |
| | | motorAbortService.create(motorAbort); |
| | | ThreadPoolExecutor threadPoolExecutor4 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor4.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | chargingOrderClient.excelEndCharge(motorAbort.getTransaction_serial_number()); |
| | | } |
| | | }); |
| | | break; |
| | | case SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION: |
| | | BmsDemandAndChargerExportationMessage bmsDemandAndChargerExportationMessage = message.getBmsDemandAndChargerExportationMessage(); |
| | |
| | | BmsDemandAndChargerExportation bmsDemandAndChargerExportation = new BmsDemandAndChargerExportation(); |
| | | BeanUtils.copyProperties(bmsDemandAndChargerExportationMessage,bmsDemandAndChargerExportation); |
| | | bmsDemandAndChargerExportationService.create(bmsDemandAndChargerExportation); |
| | | ThreadPoolExecutor threadPoolExecutor5 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor5.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | TChargingOrder chargingOrderBms = chargingOrderClient.getOrderByCode(bmsDemandAndChargerExportationMessage.getTransaction_serial_number()).getData(); |
| | | if(Objects.nonNull(chargingOrderBms)){ |
| | | chargingOrderBms.setNeedElec(bmsDemandAndChargerExportationMessage.getBms_current_requirements()); |
| | | chargingOrderClient.updateChargingOrder(chargingOrderBms); |
| | | } |
| | | } |
| | | }); |
| | | break; |
| | | case SendTagConstant.BMS_INFORMATION: |
| | | BmsInformationMessage bmsInformationMessage = message.getBmsInformationMessage(); |
| | |
| | | PlatformStartChargingReply platformStartChargingReply = new PlatformStartChargingReply(); |
| | | BeanUtils.copyProperties(platformStartChargingReplyMessage,platformStartChargingReply); |
| | | platformStartChargingReplyService.create(platformStartChargingReply); |
| | | ThreadPoolExecutor threadPoolExecutor6 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor6.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | PlatformStartChargingReplyMessageVO message1 = new com.ruoyi.order.api.vo.PlatformStartChargingReplyMessageVO(); |
| | | BeanUtils.copyProperties(platformStartChargingReplyMessage, message1); |
| | | chargingOrderClient.startChargeSuccessfully(message1); |
| | | } |
| | | }); |
| | | break; |
| | | case SendTagConstant.PLATFORM_STOP_CHARGING_REPLY: |
| | | PlatformStopChargingReplyMessage platformStopChargingReplyMessage = message.getPlatformStopChargingReplyMessage(); |
| | |
| | | PlatformStopChargingReply platformStopChargingReply = new PlatformStopChargingReply(); |
| | | BeanUtils.copyProperties(platformStopChargingReplyMessage,platformStopChargingReply); |
| | | platformStopChargingReplyService.create(platformStopChargingReply); |
| | | ThreadPoolExecutor threadPoolExecutor7 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor7.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | PlatformStopChargingReplyVO platformStopChargingReply1 = new PlatformStopChargingReplyVO(); |
| | | BeanUtils.copyProperties(platformStopChargingReply, platformStopChargingReply1); |
| | | chargingOrderClient.terminateSuccessfulResponse(platformStopChargingReply1); |
| | | } |
| | | }); |
| | | break; |
| | | case SendTagConstant.TRANSACTION_RECORD: |
| | | TransactionRecordMessage transactionRecordMessage = message.getTransactionRecordMessage(); |
| | |
| | | TransactionRecord transactionRecord = new TransactionRecord(); |
| | | BeanUtils.copyProperties(transactionRecordMessage,transactionRecord); |
| | | transactionRecordService.create(transactionRecord); |
| | | ThreadPoolExecutor threadPoolExecutor8 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor8.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 业务处理 |
| | | TChargingOrder chargingOrderRecord = chargingOrderClient.getOrderByCode(transactionRecordMessage.getTransaction_serial_number()).getData(); |
| | | if(Objects.nonNull(chargingOrderRecord)){ |
| | |
| | | //失败后添加到队列中继续处理数据 |
| | | redisTemplate.opsForSet().add(SendTagConstant.TRANSACTION_RECORD, transactionRecordMessage.getTransaction_serial_number()); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | // 添加实时上传记录结束记录 |
| | |
| | | SecurityDetection securityDetection = new SecurityDetection(); |
| | | BeanUtils.copyProperties(securityDetectionMessage,securityDetection); |
| | | securityDetectionService.create(securityDetection); |
| | | ThreadPoolExecutor threadPoolExecutor9 = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor9.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | SecurityDetectionVO securityDetection1 = new SecurityDetectionVO(); |
| | | BeanUtils.copyProperties(securityDetection, securityDetection1); |
| | | chargingOrderClient.securityDetection(securityDetection1); |
| | | } |
| | | }); |
| | | break; |
| | | default: |
| | | PlatformRemoteUpdateReplyMessage platformRemoteUpdateReplyMessage = message.getPlatformRemoteUpdateReplyMessage(); |