|  | @@ -133,7 +133,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              AjaxResult arE3 = checkOneSimStateActive(seat);
 | 
	
		
			
				|  |  |              if (arE3.isError()) {
 | 
	
	
		
			
				|  | @@ -279,7 +279,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              return ar1;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 重新最新模拟器。
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seat.getSeatId());
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seat.getSeatId());
 | 
	
		
			
				|  |  |          // 如果模拟器离线
 | 
	
		
			
				|  |  |          if (sim != null && Sim.State.ONLINE.equals(sim.getSimState())) {
 | 
	
		
			
				|  |  |              return AjaxResult.success();
 | 
	
	
		
			
				|  | @@ -348,7 +348,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          // todo:
 | 
	
		
			
				|  |  |          // 根据Seat数据遍历
 | 
	
		
			
				|  |  |          seatService.listAllEnable().forEach(seat -> {
 | 
	
		
			
				|  |  | -            Sim sim = gggSimBySeatId(seat.getSeatId());
 | 
	
		
			
				|  |  | +            Sim sim = getSimBySeatIdNewVer(seat.getSeatId());
 | 
	
		
			
				|  |  |              String simType = sim.getSimType();
 | 
	
		
			
				|  |  |              List<Fault> listF = faultService.listType3EnableBySimType(simType);
 | 
	
		
			
				|  |  |              listF.forEach(f -> {
 | 
	
	
		
			
				|  | @@ -365,7 +365,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public SimMsg debugReadSimType(final Long seatId) {
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          SimMsg sm = commBuildService.buildSendMsgReadSimType(sim.getSimNum());
 | 
	
		
			
				|  |  |          return send(sm, seat, sim, CommConst.RETRY_COUNT_0, commStrategy.getSleepShort());
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -379,7 +379,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public SimMsg debugClearOneFault(final Long seatId, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          SimMsg sm = commBuildService.buildSendMsgClearFault(sim.getSimNum(), bindHardwareMsg);
 | 
	
		
			
				|  |  |          return send(sm, seat, sim, RETRY_COUNT_CLEAR_ONE_FAULT, commStrategy.getSleepLong());
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -401,31 +401,30 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional
 | 
	
		
			
				|  |  |      public AjaxResult debugClearAllFaultBySeatId(final Long seatId) {
 | 
	
		
			
				|  |  | -        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | -        // todo:
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            AjaxResult arE3 = checkOneSimStateActive(seat);
 | 
	
		
			
				|  |  | -            if (arE3.isError()) {
 | 
	
		
			
				|  |  | -                return arE3;
 | 
	
		
			
				|  |  | +            AjaxResult ar = debugCheckSeatId(seatId);
 | 
	
		
			
				|  |  | +            if (ar.isError()) {
 | 
	
		
			
				|  |  | +                return ar;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        sim = simService.uniqueBySimNum(sim.getSimNum());
 | 
	
		
			
				|  |  | +        debugFaultService.deleteAll();
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          if (sim == null) {
 | 
	
		
			
				|  |  | -            return AjaxResult.error("清除失败,对应simNum模拟器不存在!");
 | 
	
		
			
				|  |  | +            return AjaxResult.error("清除失败,模拟器不存在!请检查模拟器线缆连接,模拟器线缆开关!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        sim = simService.selectSimBySimId(sim.getSimId());
 | 
	
		
			
				|  |  |          if (!Sim.State.ONLINE.equals(sim.getSimState())) {
 | 
	
		
			
				|  |  |              return AjaxResult.error("清除失败,模拟器尚未在线!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<SimMsg> list = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (String b : getGZBWBySimType(sim.getSimType())) {
 | 
	
		
			
				|  |  |              SimMsg sm = debugClearOneFault(seatId, b);
 | 
	
		
			
				|  |  | +            if (sm != null && !Objects.equals(sm.getResult(), SimMsg.Result.SUCCESS)) {
 | 
	
		
			
				|  |  | +                AjaxResult.success("清除失败!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              list.add(sm);
 | 
	
		
			
				|  |  | -//            if (sm != null && !sm.isOk()) {
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        debugFaultService.deleteAll();
 | 
	
		
			
				|  |  |          return AjaxResult.success("清除成功,清除当前模拟器所有故障!");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -473,7 +472,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      public SimMsg debugWriteOneFault(final Long seatId,
 | 
	
		
			
				|  |  |                                       final String bindHardwareMsg) {
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          SimMsg sm = commBuildService.buildSendMsgWriteFault(sim.getSimNum(), bindHardwareMsg);
 | 
	
		
			
				|  |  |          return send(sm, seat, sim, RETRY_COUNT_WRITE_ONE_FAULT, commStrategy.getSleepLong());
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -487,7 +486,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public List<SimMsg> debugWriteAllFault(final Long seatId) {
 | 
	
		
			
				|  |  |          List<SimMsg> list = new ArrayList<>();
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          String simType = sim.getSimType();
 | 
	
		
			
				|  |  |          for (String bind : getGZBWBySimType(simType)) {
 | 
	
		
			
				|  |  |              list.add(debugWriteOneFault(seatId, bind));
 | 
	
	
		
			
				|  | @@ -506,17 +505,24 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional
 | 
	
		
			
				|  |  |      public AjaxResult debugWriteSelectedFaultBySimNum(final Long seatId, final String[] faultIds, final Boolean checkReplace) {
 | 
	
		
			
				|  |  | -        //
 | 
	
		
			
				|  |  | -        l.info("faultIds.length = {}", faultIds.length);
 | 
	
		
			
				|  |  | +        // Check:seatId有效性
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            int deleteCount = debugFaultService.deleteAll();
 | 
	
		
			
				|  |  | -            l.info("deleteCount = {}", deleteCount);
 | 
	
		
			
				|  |  | +            AjaxResult ar = debugCheckSeatId(seatId);
 | 
	
		
			
				|  |  | +            if (ar.isError()) {
 | 
	
		
			
				|  |  | +                return ar;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        // check faultIds 有效性
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        // Check:faultIds有效性
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            if (faultIds == null || faultIds.length == 0) {
 | 
	
		
			
				|  |  | +                return AjaxResult.error("下发故障数据为空!");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 删除调试表故障数据。
 | 
	
		
			
				|  |  | +        debugFaultService.deleteAll();
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          // check sim
 | 
	
		
			
				|  |  |          // 打开socket
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -559,6 +565,28 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          return AjaxResult.success("下发故障流程执行成功!");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * debug校验seatId
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public AjaxResult debugCheckSeatId(final Long seatId) {
 | 
	
		
			
				|  |  | +        if (seatId == null || seatId <= 0) {
 | 
	
		
			
				|  |  | +            return AjaxResult.error("座次信息不正确!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        if (seat == null) {
 | 
	
		
			
				|  |  | +            return AjaxResult.error("座次信息不存在!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return AjaxResult.success();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * debug扫描所有座次模拟器
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  |      public AjaxResult debugScanAllSeat() {
 | 
	
		
			
				|  |  |          List<ScanSeatVo> list = new ArrayList<>();
 | 
	
		
			
				|  |  |          seatService.listAllEnable().forEach(seat -> {
 | 
	
	
		
			
				|  | @@ -731,7 +759,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      public SimMsg debugReadOneFaultResistance(final Long seatId,
 | 
	
		
			
				|  |  |                                                final String bindHardwareMsg) {
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          SimMsg sm = commBuildService.buildSendMsgReadFaultResistance(sim.getSimNum(), bindHardwareMsg);
 | 
	
		
			
				|  |  |          return send(sm, seat, null, RETRY_COUNT_0, commStrategy.getSleepShort());
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -743,7 +771,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public List<SimMsg> debugReadAllFaultResistance(final Long seatId) {
 | 
	
		
			
				|  |  | -        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = getSimBySeatIdNewVer(seatId);
 | 
	
		
			
				|  |  |          List<SimMsg> list = new ArrayList<>();
 | 
	
		
			
				|  |  |          String simType = simService.uniqueBySimNum(sim.getSimNum()).getSimType();
 | 
	
		
			
				|  |  |          for (String b : getGZBWBySimType(simType)) {
 | 
	
	
		
			
				|  | @@ -966,19 +994,19 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * todo:不存在部分数据
 | 
	
		
			
				|  |  | +     * checkOneSeatState 包装调用。
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @param seatId
 | 
	
		
			
				|  |  | -     * @return
 | 
	
		
			
				|  |  | +     * @return 可能为空
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public Sim gggSimBySeatId(Long seatId) {
 | 
	
		
			
				|  |  | +    public Sim getSimBySeatIdNewVer(Long seatId) {
 | 
	
		
			
				|  |  |          Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | -        AjaxResult ar01 = commCheckService.checkOneSeatState(seat, true);
 | 
	
		
			
				|  |  | -        if (ar01.isSuccess()) {
 | 
	
		
			
				|  |  | -            Long simId = seatService.selectSeatBySeatId(seatId).getCurrentSimId();
 | 
	
		
			
				|  |  | -            return simService.selectSimBySimId(simId);
 | 
	
		
			
				|  |  | +        // 执行在线监测。
 | 
	
		
			
				|  |  | +        AjaxResult ar = commCheckService.checkOneSeatState(seat, true);
 | 
	
		
			
				|  |  | +        if (ar != null) {
 | 
	
		
			
				|  |  | +            return (Sim) ar.get(AjaxResult.DATA_TAG);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            throw new IllegalArgumentException("error gggSimBySeatId");
 | 
	
		
			
				|  |  | +            return null;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |