HardwareCommDebugController.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. @GetMapping(value = "/debugWriteSelectedFaultBySimNum/{seatId}/{faultIds}")
  88. @ApiOperation("debug下发所选故障,保存[debug_fault]表中,类似开始考试")
  89. public AjaxResult debugWriteSelectedFaultBySimNum(@PathVariable("seatId") final Long seatId,
  90. @PathVariable("faultIds") final String[] faultIds,
  91. @RequestParam final Boolean checkReplace) {
  92. return commSendService.debugWriteSelectedFaultBySimNum(seatId, faultIds, checkReplace);
  93. }
  94. /**
  95. * 新版使用seatId
  96. *
  97. * @return
  98. */
  99. @GetMapping(value = "/debugScanAllSeat/")
  100. @ApiOperation("debug扫描所有座次模拟器")
  101. public AjaxResult debugRefreshAllSeat() {
  102. return commSendService.debugScanAllSeat();
  103. }
  104. /**
  105. * @return
  106. * @RequestParam final Integer localPort,
  107. * @RequestParam final String remoteIp,
  108. * @RequestParam final Integer remotePort,
  109. * @RequestParam final Boolean checkReplace
  110. */
  111. @GetMapping(value = "/debugSocketTryConnectRemoteSim/")
  112. @ApiOperation("debug尝试连接远程模拟器")
  113. public AjaxResult debugSocketTryConnectRemoteSim() {
  114. return AjaxResult.success();
  115. }
  116. @GetMapping(value = "/buildMsg/")
  117. @ApiOperation("拼写带CRC16校验的命令")
  118. public AjaxResult buildSendMsg(@RequestParam final String simNum,
  119. @RequestParam final String orn,
  120. @RequestParam final String cmd,
  121. @RequestParam final String cmdId,
  122. @RequestParam final String data) {
  123. return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
  124. }
  125. @GetMapping(value = "/buildMsgAndSend/")
  126. @ApiOperation("拼写带CRC16校验的命令并发送")
  127. public AjaxResult buildMsgAndSend(@RequestParam final String simNum,
  128. @RequestParam final String orn,
  129. @RequestParam final String cmd,
  130. @RequestParam final String cmdId,
  131. @RequestParam final String data) {
  132. // todo:
  133. return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
  134. }
  135. /**
  136. * todo:
  137. *
  138. * @return
  139. */
  140. @GetMapping(value = "/debugResetAnything/")
  141. @ApiOperation("debug重置所有")
  142. public AjaxResult debugResetAnything() {
  143. return commSendService.debugResetAnything();
  144. }
  145. }