123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- package com.ruoyi.sim.controller;
- import com.ruoyi.common.core.controller.BaseController;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.sim.service.impl.CommBuildService;
- import com.ruoyi.sim.service.impl.CommSendService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.ConfigurableApplicationContext;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.web.bind.annotation.*;
- @RestController
- @RequestMapping("/sim/debug")
- @Api("硬件通信DebugController")
- public class HardwareCommDebugController extends BaseController {
- @Autowired
- @Lazy
- private CommSendService commSendService;
- @Autowired
- @Lazy
- private CommBuildService commBuildService;
- @Autowired
- @Lazy
- private ApplicationContext applicationContext;
- @GetMapping(value = "/spring-boot-close")
- @ApiOperation("关闭本SpringBoot应用")
- public void debugReadSimType() {
- ((ConfigurableApplicationContext) applicationContext).close();
- }
- @GetMapping(value = "/debugReadSimType/{seatId}")
- @ApiOperation("debug读取模拟器类型序列号")
- public AjaxResult debugReadSimType(@PathVariable("seatId") final Long seatId) {
- return success(commSendService.debugReadSimType(seatId));
- }
- @GetMapping(value = "/debugReadOneFaultResistance/{seatId}/{bindHardwareMsg}")
- @ApiOperation("debug读取一个故障位置数据")
- public AjaxResult debugReadOneFaultResistance(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
- return success(commSendService.debugReadOneFaultResistance(seatId, bindHardwareMsg));
- }
- @GetMapping(value = "/debugReadAllFaultResistance/{seatId}")
- @ApiOperation("debug读取全部故障位置数据")
- public AjaxResult debugReadAllFaultResistance(@PathVariable("seatId") final Long seatId) {
- return success(commSendService.debugReadAllFaultResistance(seatId));
- }
- @GetMapping(value = "/debugReadAllFaultResistanceBySimNum/{seatId}")
- @ApiOperation("debug通过simNum读取一台模拟器所有故障答题值,保存[debug_fault]表中,类似交卷")
- public AjaxResult debugReadAllFaultResistanceBySimNum(@PathVariable("seatId") final Long seatId) {
- return commSendService.debugReadAllFaultResistanceBySimNum(seatId);
- }
- @GetMapping(value = "/debugClearOneFault/{seatId}/{bindHardwareMsg}")
- @ApiOperation("debug清除一个故障")
- public AjaxResult debugClearOneFault(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
- return success(commSendService.debugClearOneFault(seatId, bindHardwareMsg));
- }
- /**
- * 新版使用seatId
- *
- * @param seatId
- * @return
- */
- @GetMapping(value = "/debugClearAllFaultBySimNum/{seatId}")
- @ApiOperation("debug通过simNum清除一台模拟器所有故障")
- public AjaxResult debugClearAllFaultBySimNum(@PathVariable("seatId") final Long seatId) {
- return commSendService.debugClearAllFaultBySeatId(seatId);
- }
- /**
- * 新版使用seatId
- *
- * @return
- */
- @GetMapping(value = "/debugClearAllOnlineSimAllFault/")
- @ApiOperation("debug清除所有座次上连接的模拟器的所有故障")
- public AjaxResult debugClearAllOnlineSimAllFault() {
- return commSendService.debugClearAllSeatAllFault();
- }
- @GetMapping(value = "/debugWriteOneFault/{seatId}/{bindHardwareMsg}")
- @ApiOperation("debug下发一个故障")
- public AjaxResult debugWriteOneFault(@PathVariable("seatId") final Long seatId, @PathVariable("bindHardwareMsg") final String bindHardwareMsg) {
- return success(commSendService.debugWriteOneFault(seatId, bindHardwareMsg));
- }
- @GetMapping(value = "/debugWriteAllFault/{seatId}")
- @ApiOperation("debug下发所有故障")
- public AjaxResult debugWriteAllFault(@PathVariable("seatId") final Long seatId) {
- return success(commSendService.debugWriteAllFault(seatId));
- }
- @GetMapping(value = "/debugWriteSelectedFaultBySimNum/{seatId}/{faultIds}")
- @ApiOperation("debug下发所选故障,保存[debug_fault]表中,类似开始考试")
- public AjaxResult debugWriteSelectedFaultBySimNum(@PathVariable("seatId") final Long seatId,
- @PathVariable("faultIds") final String[] faultIds,
- @RequestParam final Boolean checkReplace) {
- return commSendService.debugWriteSelectedFaultBySimNum(seatId, faultIds, checkReplace);
- }
- /**
- * 新版使用seatId
- *
- * @return
- */
- @GetMapping(value = "/debugScanAllSeat/")
- @ApiOperation("debug扫描所有座次模拟器")
- public AjaxResult debugRefreshAllSeat() {
- return commSendService.debugScanAllSeat();
- }
- /**
- * @return
- * @RequestParam final Integer localPort,
- * @RequestParam final String remoteIp,
- * @RequestParam final Integer remotePort,
- * @RequestParam final Boolean checkReplace
- */
- @GetMapping(value = "/debugSocketTryConnectRemoteSim/")
- @ApiOperation("debug尝试连接远程模拟器")
- public AjaxResult debugSocketTryConnectRemoteSim() {
- return AjaxResult.success();
- }
- @GetMapping(value = "/buildMsg/")
- @ApiOperation("拼写带CRC16校验的命令")
- public AjaxResult buildSendMsg(@RequestParam final String simNum,
- @RequestParam final String orn,
- @RequestParam final String cmd,
- @RequestParam final String cmdId,
- @RequestParam final String data) {
- return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
- }
- @GetMapping(value = "/buildMsgAndSend/")
- @ApiOperation("拼写带CRC16校验的命令并发送")
- public AjaxResult buildMsgAndSend(@RequestParam final String simNum,
- @RequestParam final String orn,
- @RequestParam final String cmd,
- @RequestParam final String cmdId,
- @RequestParam final String data) {
- // todo:
- return commBuildService.buildSendMsgAR(simNum, orn, cmd, cmdId, data);
- }
- /**
- * todo:
- *
- * @return
- */
- @GetMapping(value = "/debugResetAnything/")
- @ApiOperation("debug重置所有")
- public AjaxResult debugResetAnything() {
- return commSendService.debugResetAnything();
- }
- }
|