HardwareCommDebugController.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. @GetMapping(value = "/debugClearAllFaultBySimNum/{seatId}")
  57. @ApiOperation("debug通过simNum清除一台模拟器所有故障")
  58. public AjaxResult debugClearAllFaultBySimNum(@PathVariable("seatId") final Long seatId) {
  59. return commSendService.debugClearAllFaultBySeatId(seatId);
  60. }
  61. @GetMapping(value = "/debugClearAllOnlineSimAllFault/")
  62. @ApiOperation("debug清除所有在线的模拟器所有故障")
  63. public AjaxResult debugClearAllOnlineSimAllFault() {
  64. return commSendService.debugClearAllOnlineSimAllFault();
  65. }
  66. @GetMapping(value = "/debugWriteOneFault/{seatId}/{bindHardwareMsg}")
  67. @ApiOperation("debug下发一个故障")
  68. public AjaxResult debugWriteOneFault(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
  69. return success(commSendService.debugWriteOneFault(seatId, bindHardwareMsg));
  70. }
  71. @GetMapping(value = "/debugWriteAllFault/{seatId}")
  72. @ApiOperation("debug下发所有故障")
  73. public AjaxResult debugWriteAllFault(@PathVariable("seatId") final Long seatId) {
  74. return success(commSendService.debugWriteAllFault(seatId));
  75. }
  76. @GetMapping(value = "/debugWriteSelectedFaultBySimNum/{seatId}/{faultIds}")
  77. @ApiOperation("debug下发所选故障,保存[debug_fault]表中,类似开始考试")
  78. public AjaxResult debugWriteSelectedFaultBySimNum(@PathVariable("seatId") final Long seatId,
  79. @PathVariable("faultIds") final String[] faultIds,
  80. @RequestParam final Boolean checkReplace) {
  81. return commSendService.debugWriteSelectedFaultBySimNum(seatId, faultIds, checkReplace);
  82. }
  83. @GetMapping(value = "/debugScanAllSeat/")
  84. @ApiOperation("debug扫描所有座次模拟器")
  85. public AjaxResult debugRefreshAllSeat() {
  86. return commSendService.debugScanAllSeat();
  87. }
  88. /**
  89. * @return
  90. * @RequestParam final Integer localPort,
  91. * @RequestParam final String remoteIp,
  92. * @RequestParam final Integer remotePort,
  93. * @RequestParam final Boolean checkReplace
  94. */
  95. @GetMapping(value = "/debugSocketTryConnectRemoteSim/")
  96. @ApiOperation("debug尝试连接远程模拟器")
  97. public AjaxResult debugSocketTryConnectRemoteSim() {
  98. return AjaxResult.success();
  99. }
  100. @GetMapping(value = "/buildMsg/")
  101. @ApiOperation("拼写带CRC16校验的命令")
  102. public AjaxResult buildSendMsg(@RequestParam final String simNum,
  103. @RequestParam final String orn,
  104. @RequestParam final String cmd,
  105. @RequestParam final String cmdId,
  106. @RequestParam final String data) {
  107. return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
  108. }
  109. @GetMapping(value = "/buildMsgAndSend/")
  110. @ApiOperation("拼写带CRC16校验的命令并发送")
  111. public AjaxResult buildMsgAndSend(@RequestParam final String simNum,
  112. @RequestParam final String orn,
  113. @RequestParam final String cmd,
  114. @RequestParam final String cmdId,
  115. @RequestParam final String data) {
  116. // todo:
  117. return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
  118. }
  119. }