| | |
| | | package com.ruoyi.dataInterchange.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.dataInterchange.api.vo.UPPlaybackMsgStartupAckVo; |
| | | import com.ruoyi.dataInterchange.dao.UPPlaybackMsgControlAckDao; |
| | | import com.ruoyi.dataInterchange.dao.UPPlaybackMsgStartupAckDao; |
| | | import com.ruoyi.dataInterchange.model.UPPlaybackMsgControlAck; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/playbackMsgStartup") |
| | | public R<UPPlaybackMsgStartupAck> playbackMsgStartup(@RequestParam("inferiorPlatformId") Integer inferiorPlatformId, @RequestParam("vehicleNo") String vehicleNo, |
| | | @RequestParam("startTime") LocalDateTime startTime, @RequestParam("endTime") LocalDateTime endTime) { |
| | | R r = downPlaybackMsgStartupService.playbackMsgStartup(inferiorPlatformId, vehicleNo, startTime, endTime); |
| | | public R<UPPlaybackMsgStartupAckVo> playbackMsgStartup(@RequestParam("inferiorPlatformId") Integer inferiorPlatformId, @RequestParam("vehicleNo") String vehicleNo, |
| | | @RequestParam("startTime") Long startTime, @RequestParam("endTime") Long endTime) { |
| | | R<String> r = downPlaybackMsgStartupService.playbackMsgStartup(inferiorPlatformId, vehicleNo, startTime, endTime); |
| | | if (200 != r.getCode()) { |
| | | return r; |
| | | return R.fail(r.getMsg()); |
| | | } |
| | | //发送成功,定时任务获取响应结果 |
| | | int num = 0; |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | Long now = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)); |
| | | while (true) { |
| | | UPPlaybackMsgStartupAck upPlaybackMsgStartupAck = upPlaybackMsgStartupAckDao.findByInferiorPlatformIdAndVehicleNoAndCreateTimeAfter(inferiorPlatformId, vehicleNo, now); |
| | | if (null == upPlaybackMsgStartupAck) { |
| | |
| | | num++; |
| | | continue; |
| | | } |
| | | if (null != upPlaybackMsgStartupAck || num >= 30) { |
| | | return R.ok(upPlaybackMsgStartupAck); |
| | | if(null != upPlaybackMsgStartupAck){ |
| | | int result = upPlaybackMsgStartupAck.getResult(); |
| | | switch (result){ |
| | | case 0: |
| | | UPPlaybackMsgStartupAckVo vo = new UPPlaybackMsgStartupAckVo(); |
| | | BeanUtils.copyProperties(upPlaybackMsgStartupAck, vo); |
| | | String encode = null; |
| | | try { |
| | | encode = URLEncoder.encode(vehicleNo, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | vo.setUrl("http://" + vo.getServerIP() + ":" + vo.getServerPort() + "/" + encode + "." + vo.getVehicleColor() + ".1.0." + r.getData()); |
| | | return R.ok(vo); |
| | | case 1: |
| | | return R.fail("失败"); |
| | | case 2: |
| | | return R.fail("不支持"); |
| | | case 3: |
| | | return R.fail("会话结束"); |
| | | case 4: |
| | | return R.fail("失效口令错误"); |
| | | case 5: |
| | | return R.fail("不满足跨域条件"); |
| | | default: |
| | | return R.fail("失败"); |
| | | } |
| | | } |
| | | if (num >= 30) { |
| | | return R.fail("失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/playbackMsgControl") |
| | | public R<Integer> playbackMsgControl(@RequestParam("inferiorPlatformId") Integer inferiorPlatformId, @RequestParam("vehicleNo") String vehicleNo, |
| | | public R playbackMsgControl(@RequestParam("inferiorPlatformId") Integer inferiorPlatformId, @RequestParam("vehicleNo") String vehicleNo, |
| | | @RequestParam("controlType") Integer controlType, @RequestParam("fastTime") Integer fastTime) { |
| | | R r = downPlaybackMsgControlService.playbackMsgControl(inferiorPlatformId, vehicleNo, controlType, fastTime); |
| | | if (200 != r.getCode()) { |
| | |
| | | } |
| | | //发送成功,定时任务获取响应结果 |
| | | int num = 0; |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | long now = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)); |
| | | while (true) { |
| | | UPPlaybackMsgControlAck upPlaybackMsgControlAck = upPlaybackMsgControlAckDao.findByInferiorPlatformIdAndVehicleNoAndCreateTimeAfter(inferiorPlatformId, vehicleNo, now); |
| | | if (null == upPlaybackMsgControlAck) { |