| | |
| | | package com.ruoyi.integration.rocket.produce; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | |
| | | import com.ruoyi.chargingPile.api.model.TFaultMessage; |
| | | import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode; |
| | | import com.ruoyi.chargingPile.api.vo.UpdateChargingPileStatusVo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.integration.api.model.*; |
| | | import com.ruoyi.integration.iotda.constant.SendTagConstant; |
| | | import com.ruoyi.integration.iotda.enums.ServiceIdMenu; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cloud.stream.annotation.StreamListener; |
| | | import org.springframework.cloud.stream.messaging.Sink; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | private UploadRealTimeMonitoringDataService uploadRealTimeMonitoringDataService; |
| | | @Resource |
| | | private AccountingStrategyDetailClient accountingStrategyDetailClient; |
| | | @Resource |
| | | private ChargingGunClient chargingGunClient; |
| | | @Resource |
| | | private FaultMessageClient faultMessageClient; |
| | | @Autowired |
| | | private ChargingHandshakeService chargingHandshakeService; |
| | | @Autowired |
| | |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | |
| | |
| | | case SendTagConstant.TRANSACTION_RECORD: |
| | | TransactionRecordMessage transactionRecordMessage = message.getTransactionRecordMessage(); |
| | | log.info("交易记录-业务消息处理:{}",transactionRecordMessage); |
| | | transactionRecordMessage.setResult(JSONObject.toJSONString(message)); |
| | | // 持久化消息 |
| | | TransactionRecord transactionRecord = new TransactionRecord(); |
| | | BeanUtils.copyProperties(transactionRecordMessage,transactionRecord); |
| | |
| | | //计算费用 |
| | | TransactionRecordMessageVO vo = new TransactionRecordMessageVO(); |
| | | BeanUtils.copyProperties(transactionRecordMessage,vo); |
| | | chargingOrderClient.endChargeBillingCharge(vo); |
| | | int code = chargingOrderClient.endChargeBillingCharge(vo).getCode(); |
| | | if(200 != code){ |
| | | //失败后添加到队列中继续处理数据 |
| | | redisTemplate.opsForSet().add(SendTagConstant.TRANSACTION_RECORD, transactionRecordMessage.getTransaction_serial_number()); |
| | | } |
| | | |
| | | |
| | | // 添加实时上传记录结束记录 |
| | | // 查询mogondb上一条数据 |
| | | UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataService.getLastDataById(transactionRecordMessage.getTransaction_serial_number()); |
| | |
| | | public void onMessage(ChargingMessage message) { |
| | | super.dispatchMessage(message); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理未正常完成费用计算的订单 |
| | | */ |
| | | public void transactionRecord(){ |
| | | Set<String> members = redisTemplate.opsForSet().members(SendTagConstant.TRANSACTION_RECORD); |
| | | for (String member : members) { |
| | | TransactionRecord transactionRecord = transactionRecordService.findOne(member); |
| | | if(null == transactionRecord){ |
| | | redisTemplate.opsForSet().remove(SendTagConstant.TRANSACTION_RECORD, member); |
| | | }else{ |
| | | TransactionRecordMessageVO vo = new TransactionRecordMessageVO(); |
| | | BeanUtils.copyProperties(transactionRecord, vo); |
| | | int code = chargingOrderClient.endChargeBillingCharge(vo).getCode(); |
| | | if(200 == code){ |
| | | redisTemplate.opsForSet().remove(SendTagConstant.TRANSACTION_RECORD, member); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |