| | |
| | | }else { |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | TVip vip = null; |
| | | if(Objects.nonNull(appUser)){ |
| | | // TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | vip = JSON.parseObject(vipJson, TVip.class); |
| | | } |
| | | } |
| | | |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 根据id查询用户信息 |
| | | TAppUser appUser = appUserClient.getUserById(userId).getData(); |
| | | TVip vip = null; |
| | | if(Objects.nonNull(appUser)){ |
| | | // 查询会员信息 |
| | | // TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | TVip vip = null; |
| | | |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | vip = JSON.parseObject(vipJson, TVip.class); |
| | | } |
| | | } |
| | | |
| | | TAccountingStrategyDetailVO accountingStrategyDetailVO; |
| | |
| | | list.add(accountingStrategyDetailVO); |
| | | list.add(accountingStrategyDetailNext); |
| | | return list; |
| | | } |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 根据id查询用户信息 |
| | | TAppUser appUser = appUserClient.getUserById(userId).getData(); |
| | | TVip vip = null; |
| | | if(Objects.nonNull(appUser)){ |
| | | // 查询会员信息 |
| | | TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | vip = JSON.parseObject(vipJson, TVip.class); |
| | | } |
| | | } |
| | | |
| | | TAccountingStrategyDetailVO accountingStrategyDetailVO; |
| | | TAccountingStrategyDetailVO accountingStrategyDetailNext; |
| | | // 获取当前时间段的计费策略明细 |
| | |
| | | list.add(accountingStrategyDetailVO); |
| | | list.add(accountingStrategyDetailNext); |
| | | return list; |
| | | } |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/qrCodeDelivery") |
| | | public String qrCodeDelivery(@RequestBody QrCodeDelivery qrCodeDelivery){ |
| | | log.info("二维码下发:{}", JSON.toJSONString(qrCodeDelivery)); |
| | | // log.info("二维码下发:{}", JSON.toJSONString(qrCodeDelivery)); |
| | | return iotMessageProduce.sendMessage(qrCodeDelivery.getCharging_pile_code(), ServiceIdMenu.QR_CODE_DELIVERY.getKey(),messageUtil.qrCodeDelivery(qrCodeDelivery)); |
| | | } |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | log.info(String.valueOf(e.getHttpStatusCode())); |
| | | log.info(e.getRequestId()); |
| | | log.info(e.getErrorCode()); |
| | | log.info(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | */ |
| | | @PostMapping(value = "/message") |
| | | public AjaxResult<String> message(@RequestBody JSONObject jsonObject) throws IOException { |
| | | log.info("接收到消息中转:{}",jsonObject); |
| | | log.info("接收到消息中转:{}",jsonObject.toJSONString()); |
| | | JSONObject body = jsonObject.getJSONObject("notify_data").getJSONObject("body"); |
| | | JSONObject content = null; |
| | | try { |
| | |
| | | if(!"}".equals(substring)){ |
| | | content1 = content1.substring(0, content1.length() - 1) + "}"; |
| | | } |
| | | log.info("content1:"+content1); |
| | | // log.info("content1:"+content1); |
| | | content = JSON.parseObject(content1); |
| | | } |
| | | JSONObject header = jsonObject.getJSONObject("notify_data").getJSONObject("header"); |
| | |
| | | String nodeId = header.getString("node_id"); // 设备编号 |
| | | String productId = header.getString("product_id"); // 产品id |
| | | String service_id = content.getString("service_id"); |
| | | log.info("服务id:{}",service_id); |
| | | // log.info("服务id:{}",service_id); |
| | | ChargingMessage chargingMessage = new ChargingMessage(); |
| | | chargingMessage.setServiceId(service_id); |
| | | // 设备消息下发 |
| | |
| | | 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); |
| | | // log.info("充电桩登录认证-返回结果:{}",result); |
| | | // 响应硬件 对时设置应答 |
| | | TimingSettingReply timingSettingReplyOnline = new TimingSettingReply(); |
| | | timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code()); |
| | |
| | | |
| | | PingMessage pingMessage = JSON.parseObject(content.toJSONString(),PingMessage.class); |
| | | //存储缓存中,5分钟有效 |
| | | redisTemplate.opsForValue().set("ping:" + pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code(), pingMessage, 5, TimeUnit.MINUTES); |
| | | // redisTemplate.opsForValue().set("ping:" + pingMessage.getCharging_pile_code() + pingMessage.getCharging_gun_code(), pingMessage, 5, TimeUnit.MINUTES); |
| | | |
| | | // 响应硬件 |
| | | Pong pong = new Pong(); |
| | |
| | | case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA: |
| | | long UPLOAD_REAL_TIME_MONITORING_DATA = System.currentTimeMillis(); |
| | | |
| | | log.info("充电实时数据上传"); |
| | | UploadRealTimeMonitoringDataMessage uploadRealTimeMonitoringDataMessage = JSON.parseObject(content.toJSONString(),UploadRealTimeMonitoringDataMessage.class); |
| | | chargingMessage.setUploadRealTimeMonitoringDataMessage(uploadRealTimeMonitoringDataMessage); |
| | | chargingMessageUtil.handleMessage(chargingMessage); |
| | |
| | | */ |
| | | @PostMapping("/sendMessage") |
| | | public String sendMessage(String code, String name, JSONObject message){ |
| | | log.info("消息下发至设备:code={},name={},message={}", code, name, message); |
| | | // log.info("消息下发至设备:code={},name={},message={}", code, name, message); |
| | | CreateMessageRequest request = new CreateMessageRequest(); |
| | | request.withDeviceId(code); |
| | | DeviceMessageRequest body = new DeviceMessageRequest(); |
| | |
| | | request.withBody(body); |
| | | try { |
| | | CreateMessageResponse response = iotBuilder.buildIot().createMessage(request); |
| | | log.info("消息下发至设备结果:{}", JSON.toJSONString(response)); |
| | | // log.info("消息下发至设备结果:{}", JSON.toJSONString(response)); |
| | | return JSON.toJSONString(response); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("消息下发至设备异常:code---{},msg---{}", code, e.getMessage()); |
| | | // log.error("消息下发至设备异常:code---{},msg---{}", code, e.getMessage()); |
| | | return e.getMessage(); |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public JSONObject onlineReply(OnlineReply onlineReply){ |
| | | log.info("登录认证应答:{}", onlineReply); |
| | | // log.info("登录认证应答:{}", onlineReply); |
| | | onlineReplyService.create(onlineReply); |
| | | return getMessageJsonString(onlineReply, ServiceIdMenu.ONLINE_REPLY.getValue()); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public JSONObject pong(Pong pong){ |
| | | log.info("心跳包应答:{}", pong); |
| | | // log.info("心跳包应答:{}", pong); |
| | | // pongService.create(pong); |
| | | //存储缓存中,5分钟有效 |
| | | redisTemplate.opsForValue().set("pong:" + pong.getCharging_pile_code() + pong.getCharging_gun_code(), pong, 5, TimeUnit.MINUTES); |
| | | // redisTemplate.opsForValue().set("pong:" + pong.getCharging_pile_code() + pong.getCharging_gun_code(), pong, 5, TimeUnit.MINUTES); |
| | | return getMessageJsonString(pong, ServiceIdMenu.PONG.getValue()); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public JSONObject billingModeVerifyReply(BillingModeVerifyReply billingModeVerifyReply){ |
| | | log.info("计费模型验证请求应答:{}", billingModeVerifyReply); |
| | | // log.info("计费模型验证请求应答:{}", billingModeVerifyReply); |
| | | // billingModeVerifyReplyService.create(billingModeVerifyReply); |
| | | return getMessageJsonString(billingModeVerifyReply, ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getValue()); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public JSONObject acquisitionBillingModeReply(AcquisitionBillingModeReply acquisitionBillingModeReply){ |
| | | log.info("计费模型验证请求应答:{}", acquisitionBillingModeReply); |
| | | // log.info("计费模型验证请求应答:{}", acquisitionBillingModeReply); |
| | | acquisitionBillingModeReplyService.create(acquisitionBillingModeReply); |
| | | return getMessageJsonString(acquisitionBillingModeReply, ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getValue()); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public JSONObject readRealTimeMonitoringData(ReadRealTimeMonitoringData readRealTimeMonitoringData){ |
| | | log.info("读取实时监测数据:{}", readRealTimeMonitoringData); |
| | | // log.info("读取实时监测数据:{}", readRealTimeMonitoringData); |
| | | readRealTimeMonitoringDataService.create(readRealTimeMonitoringData); |
| | | return getMessageJsonString(readRealTimeMonitoringData, ServiceIdMenu.READ_REAL_TIME_MONITORING_DATA.getValue()); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public JSONObject timingSettingReply(TimingSettingReply timingSettingReply){ |
| | | log.info("对时设置应答:{}", timingSettingReply); |
| | | // log.info("对时设置应答:{}", timingSettingReply); |
| | | // timingSettingReplyService.create(timingSettingReply); |
| | | return getMessageJsonString(timingSettingReply, ServiceIdMenu.TIMING_SETTING_REPLY.getValue()); |
| | | } |
| | |
| | | public JSONObject getMessageJsonString(Object object, String serviceId){ |
| | | JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object)); |
| | | jsonObject.put("service_id", serviceId); |
| | | log.info("发送数据service_id:{},发送内容:{}",serviceId,jsonObject); |
| | | // log.info("发送数据service_id:{},发送内容:{}",serviceId,jsonObject); |
| | | return jsonObject; |
| | | } |
| | | } |