HardwareCommDebugController.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. package com.ruoyi.sim.controller;
  2. import com.ruoyi.common.core.controller.BaseController;
  3. import com.ruoyi.common.core.domain.AjaxResult;
  4. import com.ruoyi.sim.service.impl.CommBuildService;
  5. import com.ruoyi.sim.service.impl.CommSendService;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.context.ApplicationContext;
  10. import org.springframework.context.ConfigurableApplicationContext;
  11. import org.springframework.context.annotation.Lazy;
  12. import org.springframework.web.bind.annotation.*;
  13. @RestController
  14. @RequestMapping("/sim/debug")
  15. @Api("硬件通信DebugController")
  16. public class HardwareCommDebugController extends BaseController {
  17. @Autowired
  18. @Lazy
  19. private CommSendService commSendService;
  20. @Autowired
  21. @Lazy
  22. private CommBuildService commBuildService;
  23. @Autowired
  24. @Lazy
  25. private ApplicationContext applicationContext;
  26. @GetMapping(value = "/spring-boot-close")
  27. @ApiOperation("关闭本SpringBoot应用")
  28. public void debugReadSimType() {
  29. ((ConfigurableApplicationContext) applicationContext).close();
  30. }
  31. @GetMapping(value = "/debugReadSimType/{seatId}")
  32. @ApiOperation("debug读取模拟器类型序列号")
  33. public AjaxResult debugReadSimType(@PathVariable("seatId") final Long seatId) {
  34. return success(commSendService.debugReadSimType(seatId));
  35. }
  36. @GetMapping(value = "/debugReadOneFaultResistance/{seatId}/{bindHardwareMsg}")
  37. @ApiOperation("debug读取一个故障位置数据")
  38. public AjaxResult debugReadOneFaultResistance(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
  39. return success(commSendService.debugReadOneFaultResistance(seatId, bindHardwareMsg));
  40. }
  41. @GetMapping(value = "/debugReadAllFaultResistance/{seatId}")
  42. @ApiOperation("debug读取全部故障位置数据")
  43. public AjaxResult debugReadAllFaultResistance(@PathVariable("seatId") final Long seatId) {
  44. return success(commSendService.debugReadAllFaultResistance(seatId));
  45. }
  46. @GetMapping(value = "/debugReadAllFaultResistanceBySimNum/{seatId}")
  47. @ApiOperation("debug通过simNum读取一台模拟器所有故障答题值,保存[debug_fault]表中,类似交卷")
  48. public AjaxResult debugReadAllFaultResistanceBySimNum(@PathVariable("seatId") final Long seatId) {
  49. return commSendService.debugReadAllFaultResistanceBySimNum(seatId);
  50. }
  51. @GetMapping(value = "/debugClearOneFault/{seatId}/{bindHardwareMsg}")
  52. @ApiOperation("debug清除一个故障")
  53. public AjaxResult debugClearOneFault(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
  54. return success(commSendService.debugClearOneFault(seatId, bindHardwareMsg));
  55. }
  56. /**
  57. * 新版使用seatId
  58. *
  59. * @param seatId
  60. * @return
  61. */
  62. @GetMapping(value = "/debugClearAllFaultBySimNum/{seatId}")
  63. @ApiOperation("debug通过simNum清除一台模拟器所有故障")
  64. public AjaxResult debugClearAllFaultBySimNum(@PathVariable("seatId") final Long seatId) {
  65. return commSendService.debugClearAllFaultBySeatId(seatId);
  66. }
  67. /**
  68. * 新版使用seatId
  69. *
  70. * @return
  71. */
  72. @GetMapping(value = "/debugClearAllOnlineSimAllFault/")
  73. @ApiOperation("debug清除所有座次上连接的模拟器的所有故障")
  74. public AjaxResult debugClearAllOnlineSimAllFault() {
  75. return commSendService.debugClearAllSeatAllFault();
  76. }
  77. @GetMapping(value = "/debugWriteOneFault/{seatId}/{bindHardwareMsg}")
  78. @ApiOperation("debug下发一个故障")
  79. public AjaxResult debugWriteOneFault(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
  80. return success(commSendService.debugWriteOneFault(seatId, bindHardwareMsg));
  81. }
  82. @GetMapping(value = "/debugWriteAllFault/{seatId}")
  83. @ApiOperation("debug下发所有故障")
  84. public AjaxResult debugWriteAllFault(@PathVariable("seatId") final Long seatId) {
  85. return success(commSendService.debugWriteAllFault(seatId));
  86. }
  87. /**
  88. * 新版使用seatId
  89. *
  90. * @return
  91. */
  92. @GetMapping(value = "/debugWriteSelectedFaultBySimNum/{seatId}/{faultIds}")
  93. @ApiOperation("debug下发所选故障,保存[debug_fault]表中,类似开始考试")
  94. public AjaxResult debugWriteSelectedFaultBySimNum(@PathVariable("seatId") final Long seatId,
  95. @PathVariable("faultIds") final String[] faultIds,
  96. @RequestParam final Boolean checkReplace) {
  97. return commSendService.debugWriteSelectedFaultBySeatId(seatId, faultIds, checkReplace);
  98. }
  99. /**
  100. * 新版使用seatId
  101. *
  102. * @return
  103. */
  104. @GetMapping(value = "/debugScanAllSeat/")
  105. @ApiOperation("debug扫描所有座次模拟器")
  106. public AjaxResult debugRefreshAllSeat() {
  107. return commSendService.debugScanAllSeat();
  108. }
  109. /**
  110. * @return
  111. * @RequestParam final Integer localPort,
  112. * @RequestParam final String remoteIp,
  113. * @RequestParam final Integer remotePort,
  114. * @RequestParam final Boolean checkReplace
  115. */
  116. @GetMapping(value = "/debugSocketTryConnectRemoteSim/")
  117. @ApiOperation("debug尝试连接远程模拟器")
  118. public AjaxResult debugSocketTryConnectRemoteSim() {
  119. return AjaxResult.success();
  120. }
  121. @GetMapping(value = "/buildMsg/")
  122. @ApiOperation("拼写带CRC16校验的命令,但是不发送")
  123. public AjaxResult buildSendMsg(@RequestParam final String simNum,
  124. @RequestParam final String orn,
  125. @RequestParam final String cmd,
  126. @RequestParam final String cmdId,
  127. @RequestParam final String data) {
  128. return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
  129. }
  130. @GetMapping(value = "/buildMsgAndSend/{seatId}")
  131. @ApiOperation("拼写带CRC16校验的命令,并发送,返回响应结果")
  132. public AjaxResult buildMsgAndSend(@PathVariable("seatId") final Long seatId,
  133. @RequestParam final String simNum,
  134. @RequestParam final String orn,
  135. @RequestParam final String cmd,
  136. @RequestParam final String cmdId,
  137. @RequestParam final String data) {
  138. return commBuildService.buildSendMsgAndSendAR(seatId, simNum, orn, cmd, cmdId, data);
  139. }
  140. /**
  141. * todo:
  142. *
  143. * @return
  144. */
  145. @GetMapping(value = "/debugResetAnything/")
  146. @ApiOperation("debug重置所有")
  147. public AjaxResult debugResetAnything() {
  148. return commSendService.debugResetAnything();
  149. }
  150. }