|  | @@ -4,7 +4,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.ruoyi.sim.config.SimConfig;
 | 
	
		
			
				|  |  |  import com.ruoyi.sim.config.SimDebugConfig;
 | 
	
		
			
				|  |  | +import com.ruoyi.sim.constant.CommConst;
 | 
	
		
			
				|  |  |  import com.ruoyi.sim.domain.*;
 | 
	
		
			
				|  |  | +import com.ruoyi.sim.domain.vo.SimSocketVo;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
	
		
			
				|  | @@ -16,9 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.io.InputStream;
 | 
	
		
			
				|  |  |  import java.io.OutputStream;
 | 
	
		
			
				|  |  | -import java.net.InetAddress;
 | 
	
		
			
				|  |  |  import java.net.Socket;
 | 
	
		
			
				|  |  | -import java.net.UnknownHostException;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import static com.ruoyi.sim.constant.CommConst.*;
 | 
	
	
		
			
				|  | @@ -36,6 +36,8 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private CommReceiveService simReceiveService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | +    private SeatService seatService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  |      private SimService simService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private FaultService faultService;
 | 
	
	
		
			
				|  | @@ -49,8 +51,13 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      private CommBuildService commBuildService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private DebugFaultService debugFaultService;
 | 
	
		
			
				|  |  | +    // private SocketOldService socketOldService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SocketService socketService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private FailedCountService failedCountService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private SocketOldService socketOldService;
 | 
	
		
			
				|  |  | +    private CommCheckService commCheckService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      CommReceiveService commReceiveService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
	
		
			
				|  | @@ -72,13 +79,12 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              List<RealExamFault> listRef = realExamFaultService.listAllType2State2and3ByExamId(e.getExamId());
 | 
	
		
			
				|  |  |              listRef.forEach(ref -> {
 | 
	
		
			
				|  |  | -                Sim s = simService.selectSimBySimId(e.getSimId());
 | 
	
		
			
				|  |  | +                RealExam re = realExamService.selectRealExamByExamId(ref.getExamId());
 | 
	
		
			
				|  |  | +                Seat seat = seatService.selectSeatBySeatId(re.getSeatId());
 | 
	
		
			
				|  |  | +                Sim sim = simService.selectSimBySimId(e.getSimId());
 | 
	
		
			
				|  |  |                  Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
 | 
	
		
			
				|  |  | -                if (f != null &&
 | 
	
		
			
				|  |  | -                        Fault.Type.REAL_GZBW.equals(f.getFaultType()) &&
 | 
	
		
			
				|  |  | -                        Fault.State.ENABLE.equals(f.getFaultState())
 | 
	
		
			
				|  |  | -                ) {
 | 
	
		
			
				|  |  | -                    readOneSimOneFaultResistance(s, ref, f, null);
 | 
	
		
			
				|  |  | +                if (f != null && Fault.Type.REAL_GZBW.equals(f.getFaultType()) && Fault.State.ENABLE.equals(f.getFaultState())) {
 | 
	
		
			
				|  |  | +                    readOneSimOneFaultResistance(seat, sim, ref, f, null);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |          });
 | 
	
	
		
			
				|  | @@ -96,9 +102,10 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          l.info("readOneExamAtLast");
 | 
	
		
			
				|  |  |          List<RealExamFault> list = realExamFaultService.listAllType2State2and3ByExamId(re.getExamId());
 | 
	
		
			
				|  |  |          for (RealExamFault ref : list) {
 | 
	
		
			
				|  |  | -            Sim s = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  | +            Seat seat = seatService.selectSeatBySeatId(re.getSeatId());
 | 
	
		
			
				|  |  | +            Sim sim = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  |              Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
 | 
	
		
			
				|  |  | -            readOneSimOneFaultResistance(s, ref, f, RealExamFault.State.FINISH);
 | 
	
		
			
				|  |  | +            readOneSimOneFaultResistance(seat, sim, ref, f, RealExamFault.State.FINISH);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 计算扣分。
 | 
	
		
			
				|  |  |          // 最后都读取到,才算扣分。
 | 
	
	
		
			
				|  | @@ -108,36 +115,34 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public void readOneSimAtLastByDebug(Sim s) {
 | 
	
		
			
				|  |  | +    public void readOneSimAtLastByDebug(Seat seat, Sim sim) {
 | 
	
		
			
				|  |  |          l.info("readOneSimAtLastByDebug");
 | 
	
		
			
				|  |  | -        List<Fault> list = faultService.listType3(s.getSimType());
 | 
	
		
			
				|  |  | +        List<Fault> list = faultService.listType3(sim.getSimType());
 | 
	
		
			
				|  |  |          for (Fault f : list) {
 | 
	
		
			
				|  |  | -            readOneSimOneFaultResistance(s, null, f, null);
 | 
	
		
			
				|  |  | +            readOneSimOneFaultResistance(seat, sim, null, f, null);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public AjaxResult debugReadAllFaultResistanceBySimNum(String simNum) {
 | 
	
		
			
				|  |  | +    public AjaxResult debugReadAllFaultResistanceBySimNum(final Long seatId) {
 | 
	
		
			
				|  |  |          // check
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  |          // 打开socket
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            AjaxResult ar1 = socketOldService.openSocket();
 | 
	
		
			
				|  |  | -            if (ar1.isError()) {
 | 
	
		
			
				|  |  | -                return ar1;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            socketService.openAll();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  | -        Sim s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            AjaxResult arE3 = checkOneSimStateActive(s);
 | 
	
		
			
				|  |  | +            AjaxResult arE3 = checkOneSimStateActive(seat);
 | 
	
		
			
				|  |  |              if (arE3.isError()) {
 | 
	
		
			
				|  |  |                  return arE3;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | +        sim = simService.uniqueBySimNum(sim.getSimNum());
 | 
	
		
			
				|  |  |          // todo: aj改造
 | 
	
		
			
				|  |  | -        readOneSimAtLastByDebug(s);
 | 
	
		
			
				|  |  | +        readOneSimAtLastByDebug(seat, sim);
 | 
	
		
			
				|  |  |          return AjaxResult.success("成功读取!");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -169,7 +174,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public void scheduledReadSim() {
 | 
	
		
			
				|  |  |          l.info("scheduledReadSim");
 | 
	
		
			
				|  |  | -        if (!realExamCollectionService.existOpened()) {
 | 
	
		
			
				|  |  | +        if (!realExamCollectionService.existAtLeastOneOpened()) {
 | 
	
		
			
				|  |  |              l.info("没有open的考试集合");
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -198,15 +203,6 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          // debugReadSimType(simNum);
 | 
	
		
			
				|  |  |          // l.info("bRea:" + bRea);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            Socket s = socketOldService.getCachedSocket();
 | 
	
		
			
				|  |  | -            l.info("cachedSocket.isConnected():" + s.isConnected());
 | 
	
		
			
				|  |  | -            l.info("cachedSocket.isBound():" + s.isBound());
 | 
	
		
			
				|  |  | -            l.info("cachedSocket.isClosed():" + s.isClosed());
 | 
	
		
			
				|  |  | -            l.info("cachedSocket.isInputShutdown():" + s.isInputShutdown());
 | 
	
		
			
				|  |  | -            l.info("cachedSocket.isOutputShutdown():" + s.isOutputShutdown());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  //            debugReadAllFaultResistance(simNum, simType);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  //            debugWriteAllFault(simNum, simType);
 | 
	
	
		
			
				|  | @@ -224,7 +220,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 连接情况 的 定时任务。
 | 
	
		
			
				|  |  | -     * 执行频率: 3min
 | 
	
		
			
				|  |  | +     * 执行频率: 5min
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public void scheduledConnect() {
 | 
	
		
			
				|  |  |          l.info("scheduled####Connect  连接情况 的 定时任务");
 | 
	
	
		
			
				|  | @@ -232,113 +228,63 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              l.info("连接情况 的 定时任务被禁用!");
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (!realExamCollectionService.existOpened()) {
 | 
	
		
			
				|  |  | -            l.info("没有open的考试集合");
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if (!isReachable(config.getRouterIp())) {
 | 
	
		
			
				|  |  | -            l.warn("ping RouterIp not ok");
 | 
	
		
			
				|  |  | -            simService.updateAllEnableState(Sim.State.GATEWAY_OFFLINE);
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if (!isReachable(config.getRs485Ip())) {
 | 
	
		
			
				|  |  | -            l.warn("ping Rs485Ip not ok");
 | 
	
		
			
				|  |  | -            simService.updateAllEnableState(Sim.State.GATEWAY_OFFLINE);
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        socketOldService.openSocket();
 | 
	
		
			
				|  |  | -        if (socketOldService.isCachedSocketOk()) {
 | 
	
		
			
				|  |  | -            checkAllSimState();
 | 
	
		
			
				|  |  | +        // 暂时注释
 | 
	
		
			
				|  |  | +//        if (!realExamCollectionService.existAtLeastOneOpened()) {
 | 
	
		
			
				|  |  | +//            l.info("没有open的任何集合");
 | 
	
		
			
				|  |  | +//            return;
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            AjaxResult ar01 = commCheckService.checkRouterState(config.getRouterIp());
 | 
	
		
			
				|  |  | +            if (ar01.isError()) {
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            seatService.listAllRs485Ip().forEach(rs485Ip -> {
 | 
	
		
			
				|  |  | +                commCheckService.checkPingRs485State(rs485Ip);
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        // SocketOldService实现
 | 
	
		
			
				|  |  | +        // socketOldService.openSocket();
 | 
	
		
			
				|  |  | +        socketService.openAll();
 | 
	
		
			
				|  |  | +        // SocketOldService实现
 | 
	
		
			
				|  |  | +//        if (socketOldService.isCachedSocketOk()) {
 | 
	
		
			
				|  |  | +//            checkAllSeatAndSimState();
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  | +        commCheckService.checkAllSeatAndSimState();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 主动更新模拟器状态。
 | 
	
		
			
				|  |  | +     * todo:需要重新考虑
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param seat
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public AjaxResult checkOneSimStateActive(Sim s) {
 | 
	
		
			
				|  |  | -        final long simId = s.getSimId();
 | 
	
		
			
				|  |  | +    public AjaxResult checkOneSimStateActive(Seat seat) {
 | 
	
		
			
				|  |  |          // 这句可能会调整模拟器状态,后面需要重新查询。
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            AjaxResult ar1 = checkOneSimState(s, true);
 | 
	
		
			
				|  |  | -            if (ar1.isError()) {
 | 
	
		
			
				|  |  | -                return ar1;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +        commCheckService.checkOneSeatState(seat, true);
 | 
	
		
			
				|  |  | +        AjaxResult ar1 = commCheckService.checkOneSimState(seat, true);
 | 
	
		
			
				|  |  | +        if (ar1.isError()) {
 | 
	
		
			
				|  |  | +            return ar1;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 重新最新模拟器。
 | 
	
		
			
				|  |  | -        s = simService.selectSimBySimId(simId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seat.getSeatId());
 | 
	
		
			
				|  |  |          // 如果模拟器离线
 | 
	
		
			
				|  |  | -        if (s != null && Sim.State.ONLINE.equals(s.getSimState())) {
 | 
	
		
			
				|  |  | +        if (sim != null && Sim.State.ONLINE.equals(sim.getSimState())) {
 | 
	
		
			
				|  |  |              return AjaxResult.success();
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              return AjaxResult.error("未连接模拟器,请检查连接!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | -     * @param important true 重试次数不同,也会进行序列号检查。
 | 
	
		
			
				|  |  | -     * @return
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    public AjaxResult checkOneSimState(final Sim s, final boolean important) {
 | 
	
		
			
				|  |  | -        // check
 | 
	
		
			
				|  |  | -        if (s == null) {
 | 
	
		
			
				|  |  | -            return AjaxResult.error("sim is null");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if (Sim.State.DISABLE.equals(s.getSimState())) {
 | 
	
		
			
				|  |  | -            l.warn("sim DISABLE,模拟器被禁用,sim = {}", s);
 | 
	
		
			
				|  |  | -            return AjaxResult.error("模拟器被禁用");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        if (StringUtils.isBlank(s.getSimType()) || StringUtils.isBlank(s.getSimNum())) {
 | 
	
		
			
				|  |  | -            l.warn("sim error data {}", s);
 | 
	
		
			
				|  |  | -            return AjaxResult.error("模拟器数据错误。");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        //
 | 
	
		
			
				|  |  | -        SimMsg smS = commBuildService.buildSendMsgReadSimType(s.getSimNum());
 | 
	
		
			
				|  |  | -        int retryCount = RETRY_COUNT_0;
 | 
	
		
			
				|  |  | -        long sleep = SLEEP_SHORT;
 | 
	
		
			
				|  |  | -        if (important) {
 | 
	
		
			
				|  |  | -            retryCount = RETRY_COUNT_QUERY_SN_IMPORTANT;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        SimMsg smR = send(smS, s, retryCount, sleep);
 | 
	
		
			
				|  |  | -        if (StringUtils.isNotBlank(smR.getReceiveMsg())) {
 | 
	
		
			
				|  |  | -            l.info("isNotBlank");
 | 
	
		
			
				|  |  | -            socketOldService.commFailCountClearOne(s.getSimId());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        simReceiveService.checkOneSimState(smR, s);
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (important) {
 | 
	
		
			
				|  |  | -                AjaxResult ar1 = simReceiveService.checkOneSimSn(smR, s);
 | 
	
		
			
				|  |  | -                if (ar1.isError()) {
 | 
	
		
			
				|  |  | -                    return ar1;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return AjaxResult.success();
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * 查找所有没有被手动禁用,并order by sim_num的模拟器列表。检查所有模拟器状态。
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    public void checkAllSimState() {
 | 
	
		
			
				|  |  | -        // RealExamCollection ecF = realExamCollectionService.selectRealExamCollectionOpened();
 | 
	
		
			
				|  |  | -        // l.info("ecF.getSimType() = {}", ecF.getSimType());
 | 
	
		
			
				|  |  | -        // if (ecF != null) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // }
 | 
	
		
			
				|  |  | -        List<Sim> list = simService.listAllEnable(); // ecF.getSimType()
 | 
	
		
			
				|  |  | -        l.info("checkAllSimState list.size() = {}", list.size());
 | 
	
		
			
				|  |  | -        list.forEach(s -> {
 | 
	
		
			
				|  |  | -            checkOneSimState(s, false);
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      @Async("tp-comm")
 | 
	
		
			
				|  |  |      public void checkAllSimStateAsync() {
 | 
	
		
			
				|  |  | -        checkAllSimState();
 | 
	
		
			
				|  |  | +        commCheckService.checkAllSeatAndSimState();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -360,27 +306,26 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              l.info("清除exam list = {}", list.size());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          assert list != null;
 | 
	
		
			
				|  |  | -        list
 | 
	
		
			
				|  |  | -                .forEach(ref -> {
 | 
	
		
			
				|  |  | -                    Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
 | 
	
		
			
				|  |  | -                    if (faultService.isDisable(f.getFaultId())) {
 | 
	
		
			
				|  |  | -                        l.warn("故障 {} -被禁用", f.getName());
 | 
	
		
			
				|  |  | -                        throw new IllegalArgumentException("故障被禁用");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    Sim s = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  | -                    // check
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(re.getSeatId());
 | 
	
		
			
				|  |  | +        list.forEach(ref -> {
 | 
	
		
			
				|  |  | +            Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
 | 
	
		
			
				|  |  | +            if (faultService.isDisable(f.getFaultId())) {
 | 
	
		
			
				|  |  | +                l.warn("故障 {} -被禁用", f.getName());
 | 
	
		
			
				|  |  | +                throw new IllegalArgumentException("故障被禁用");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Sim sim = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  | +            // check
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    //
 | 
	
		
			
				|  |  | -                    clearOneSimOneFault(s, ref, f);
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | +            //
 | 
	
		
			
				|  |  | +            clearOneSimOneFault(seat, sim, ref, f);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public void clearOneSimAllFaultBySim(Sim s) {
 | 
	
		
			
				|  |  | -        l.info("clearOneSimAllFaultBySim = {}", s);
 | 
	
		
			
				|  |  | -        faultService.listType3EnableBySimType(s.getSimType())
 | 
	
		
			
				|  |  | -                .forEach(f -> {
 | 
	
		
			
				|  |  | -                    clearOneSimOneFault(s, null, f);
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | +    public void clearOneSimAllFaultBySim(Seat seat, Sim sim) {
 | 
	
		
			
				|  |  | +        l.info("clearOneSimAllFaultBySim = {}", sim);
 | 
	
		
			
				|  |  | +        faultService.listType3EnableBySimType(sim.getSimType()).forEach(f -> {
 | 
	
		
			
				|  |  | +            clearOneSimOneFault(seat, sim, null, f);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -395,11 +340,13 @@ public class CommSendService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void clearAll() {
 | 
	
		
			
				|  |  |          // todo:
 | 
	
		
			
				|  |  | -        simService.listAllEnable().forEach(s -> {
 | 
	
		
			
				|  |  | -            String simType = s.getSimType();
 | 
	
		
			
				|  |  | +        // 根据Seat数据遍历
 | 
	
		
			
				|  |  | +        seatService.listAllEnable().forEach(seat -> {
 | 
	
		
			
				|  |  | +            Sim sim = gggSimBySeatId(seat.getSeatId());
 | 
	
		
			
				|  |  | +            String simType = sim.getSimType();
 | 
	
		
			
				|  |  |              List<Fault> listF = faultService.listType3EnableBySimType(simType);
 | 
	
		
			
				|  |  |              listF.forEach(f -> {
 | 
	
		
			
				|  |  | -                clearOneSimOneFault(s, null, f);
 | 
	
		
			
				|  |  | +                clearOneSimOneFault(seat, sim, null, f);
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -407,31 +354,34 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug读取模拟器类型序列号
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public SimMsg debugReadSimType(final String simNum) {
 | 
	
		
			
				|  |  | -        SimMsg sm = commBuildService.buildSendMsgReadSimType(simNum);
 | 
	
		
			
				|  |  | -        return send(sm, null, RETRY_COUNT_0, SLEEP_SHORT);
 | 
	
		
			
				|  |  | +    public SimMsg debugReadSimType(final Long seatId) {
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        SimMsg sm = commBuildService.buildSendMsgReadSimType(sim.getSimNum());
 | 
	
		
			
				|  |  | +        return send(sm, seat, sim, CommConst.RETRY_COUNT_0, CommConst.SLEEP_SHORT);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug清除一个故障
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @param bindHardwareMsg
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public SimMsg debugClearOneFault(final String simNum, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  | -        SimMsg sm = commBuildService.buildSendMsgClearFault(simNum, bindHardwareMsg);
 | 
	
		
			
				|  |  | -        Sim s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | -        return send(sm, s, RETRY_COUNT_CLEAR_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | +    public SimMsg debugClearOneFault(final Long seatId, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        SimMsg sm = commBuildService.buildSendMsgClearFault(sim.getSimNum(), bindHardwareMsg);
 | 
	
		
			
				|  |  | +        return send(sm, seat, sim, RETRY_COUNT_CLEAR_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public AjaxResult debugClearAllOnlineSimAllFault() {
 | 
	
		
			
				|  |  |          l.info("debugClearAllOnlineSimAllFault");
 | 
	
		
			
				|  |  |          simService.listAllOnline().forEach(s -> {
 | 
	
		
			
				|  |  | -            AjaxResult ar = debugClearAllFaultBySimNum(s.getSimNum());
 | 
	
		
			
				|  |  | +            // AjaxResult ar = debugClearAllFaultBySeatId(0);// todo:尚未实现
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          debugFaultService.deleteAll();
 | 
	
		
			
				|  |  |          return AjaxResult.success("清除成功,清除所有在线模拟器所有故障!");
 | 
	
	
		
			
				|  | @@ -440,28 +390,30 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug清除所有故障
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional
 | 
	
		
			
				|  |  | -    public AjaxResult debugClearAllFaultBySimNum(final String simNum) {
 | 
	
		
			
				|  |  | -        Sim s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | +    public AjaxResult debugClearAllFaultBySeatId(final Long seatId) {
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        // todo:
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            AjaxResult arE3 = checkOneSimStateActive(s);
 | 
	
		
			
				|  |  | +            AjaxResult arE3 = checkOneSimStateActive(seat);
 | 
	
		
			
				|  |  |              if (arE3.isError()) {
 | 
	
		
			
				|  |  |                  return arE3;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | -        if (s == null) {
 | 
	
		
			
				|  |  | +        sim = simService.uniqueBySimNum(sim.getSimNum());
 | 
	
		
			
				|  |  | +        if (sim == null) {
 | 
	
		
			
				|  |  |              return AjaxResult.error("清除失败,对应simNum模拟器不存在!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (!Sim.State.ONLINE.equals(s.getSimState())) {
 | 
	
		
			
				|  |  | +        if (!Sim.State.ONLINE.equals(sim.getSimState())) {
 | 
	
		
			
				|  |  |              return AjaxResult.error("清除失败,模拟器尚未在线!");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<SimMsg> list = new ArrayList<>();
 | 
	
		
			
				|  |  | -        for (String b : getGZBWBySimType(s.getSimType())) {
 | 
	
		
			
				|  |  | -            SimMsg sm = debugClearOneFault(simNum, b);
 | 
	
		
			
				|  |  | +        for (String b : getGZBWBySimType(sim.getSimType())) {
 | 
	
		
			
				|  |  | +            SimMsg sm = debugClearOneFault(seatId, b);
 | 
	
		
			
				|  |  |              list.add(sm);
 | 
	
		
			
				|  |  |              if (sm != null && !sm.getOk()) {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -472,20 +424,19 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param sim
 | 
	
		
			
				|  |  |       * @param reF 可以为空,表示不关联考试的,单独执行的。调试模式下为空。
 | 
	
		
			
				|  |  |       * @param f
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public void clearOneSimOneFault(Sim s, RealExamFault reF, Fault f) {
 | 
	
		
			
				|  |  | -        l.info("clearOneSimOneFault 清除One故障:getSimNum = {},getBindHardwareMsg = {},fault.getName = {}",
 | 
	
		
			
				|  |  | -                s.getSimNum(), f.getBindHardwareMsg(), f.getName());
 | 
	
		
			
				|  |  | +    public void clearOneSimOneFault(Seat seat, Sim sim, RealExamFault reF, Fault f) {
 | 
	
		
			
				|  |  | +        l.info("clearOneSimOneFault 清除One故障:getSimNum = {},getBindHardwareMsg = {},fault.getName = {}", sim.getSimNum(), f.getBindHardwareMsg(), f.getName());
 | 
	
		
			
				|  |  |          // check todo:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // step1
 | 
	
		
			
				|  |  | -        SimMsg smS = commBuildService.buildSendMsgClearFault(s.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | -        SimMsg smR = send(smS, s, RETRY_COUNT_CLEAR_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | +        SimMsg smS = commBuildService.buildSendMsgClearFault(sim.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | +        SimMsg smR = send(smS, seat, sim, RETRY_COUNT_CLEAR_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  |          if (reF != null) {
 | 
	
		
			
				|  |  | -            simReceiveService.clearOneFault(smR, s, reF, f);
 | 
	
		
			
				|  |  | +            simReceiveService.clearOneFault(smR, sim, reF, f);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              l.info("reF == null");
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -508,29 +459,31 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug下发一个故障
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @param bindHardwareMsg
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       * @throws IOException
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public SimMsg debugWriteOneFault(final String simNum, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  | -        SimMsg sm = commBuildService.buildSendMsgWriteFault(simNum, bindHardwareMsg);
 | 
	
		
			
				|  |  | -        return send(sm, null, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | +    public SimMsg debugWriteOneFault(final Long seatId, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        SimMsg sm = commBuildService.buildSendMsgWriteFault(sim.getSimNum(), bindHardwareMsg);
 | 
	
		
			
				|  |  | +        return send(sm, seat, sim, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug下发所有故障
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       * @throws IOException
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public List<SimMsg> debugWriteAllFault(final String simNum) {
 | 
	
		
			
				|  |  | +    public List<SimMsg> debugWriteAllFault(final Long seatId) {
 | 
	
		
			
				|  |  |          List<SimMsg> list = new ArrayList<>();
 | 
	
		
			
				|  |  | -        Sim s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | -        String simType = s.getSimType();
 | 
	
		
			
				|  |  | -        for (String b : getGZBWBySimType(simType)) {
 | 
	
		
			
				|  |  | -            list.add(debugWriteOneFault(simNum, b));
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        String simType = sim.getSimType();
 | 
	
		
			
				|  |  | +        for (String bind : getGZBWBySimType(simType)) {
 | 
	
		
			
				|  |  | +            list.add(debugWriteOneFault(seatId, bind));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return list;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -539,15 +492,13 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       * todo:尚未实现
 | 
	
		
			
				|  |  |       * 实现方式类似 studentStartRealExam方法。
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @param faultIds
 | 
	
		
			
				|  |  |       * @param checkReplace 是否进行可换件检查
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Transactional
 | 
	
		
			
				|  |  | -    public AjaxResult debugWriteSelectedFaultBySimNum(final String simNum,
 | 
	
		
			
				|  |  | -                                                      final String[] faultIds,
 | 
	
		
			
				|  |  | -                                                      final Boolean checkReplace) {
 | 
	
		
			
				|  |  | +    public AjaxResult debugWriteSelectedFaultBySimNum(final Long seatId, final String[] faultIds, final Boolean checkReplace) {
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  |          l.info("faultIds.length = {}", faultIds.length);
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -557,29 +508,26 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          // check faultIds 有效性
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  | -        Sim s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  |          // check sim
 | 
	
		
			
				|  |  |          // 打开socket
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            AjaxResult ar1 = socketOldService.openSocket();
 | 
	
		
			
				|  |  | -            l.info("ar1 = {}", ar1);
 | 
	
		
			
				|  |  | -            if (ar1.isError()) {
 | 
	
		
			
				|  |  | -                return ar1;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            socketService.openAll();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // Step 1 主动查询一次模拟器状态。
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            AjaxResult arE3 = checkOneSimStateActive(s);
 | 
	
		
			
				|  |  | +            AjaxResult arE3 = checkOneSimStateActive(seat);
 | 
	
		
			
				|  |  |              if (arE3.isError()) {
 | 
	
		
			
				|  |  |                  return arE3;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        s = simService.uniqueBySimNum(simNum);
 | 
	
		
			
				|  |  | +        sim = simService.uniqueBySimNum(sim.getSimNum());
 | 
	
		
			
				|  |  |          // Step 2
 | 
	
		
			
				|  |  |          // msg判断,是否含有"故障部位"字符串
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (checkReplace) {
 | 
	
		
			
				|  |  | -                AjaxResult arE2 = readOneSimAllFaultCheck(s);
 | 
	
		
			
				|  |  | +                AjaxResult arE2 = readOneSimAllFaultCheck(seat, sim);
 | 
	
		
			
				|  |  |                  if (arE2.isError()) {
 | 
	
		
			
				|  |  |                      return arE2;
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -587,7 +535,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // Step 3 清除对应一台模拟器 所有故障部位故障。
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            clearOneSimAllFaultBySim(s);
 | 
	
		
			
				|  |  | +            clearOneSimAllFaultBySim(seat, sim);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // Step 4 下发对应一台模拟器 出题选中的 故障位置故障。
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -595,11 +543,11 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              for (int i = 0; i < faultIds.length; i++) {
 | 
	
		
			
				|  |  |                  faults[i] = faultService.selectFaultByFaultId(faultIds[i]);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            writeOneSimAllSelectFaultByDebug(s, faults);
 | 
	
		
			
				|  |  | +            writeOneSimAllSelectFaultByDebug(seat, sim, faults);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // Step 5 读取
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -            readOneSimAllFaultFirstTimeBySim(s, faultIds);
 | 
	
		
			
				|  |  | +            readOneSimAllFaultFirstTimeBySim(seat, sim, faultIds);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return AjaxResult.success("下发故障流程执行成功!");
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -634,41 +582,42 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          realExamService.updateOneState(re.getExamId(), RealExam.State.SIM_WRITING);
 | 
	
		
			
				|  |  |          List<RealExamFault> list = realExamFaultService.listAllType2FlagYesClearedStateByExamId(re.getExamId());
 | 
	
		
			
				|  |  |          for (RealExamFault ref : list) {
 | 
	
		
			
				|  |  | -            Sim s = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  | +            Seat seat = seatService.selectSeatBySeatId(re.getSeatId());
 | 
	
		
			
				|  |  | +            Sim sim = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  |              Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
 | 
	
		
			
				|  |  |              // 选中的才下发。
 | 
	
		
			
				|  |  | -            writeOneSimOneFault(s, ref, f);
 | 
	
		
			
				|  |  | +            writeOneSimOneFault(seat, sim, ref, f);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public void writeOneSimAllSelectFaultByDebug(Sim s, Fault[] faults) {
 | 
	
		
			
				|  |  | +    public void writeOneSimAllSelectFaultByDebug(Seat seat, Sim sim, Fault[] faults) {
 | 
	
		
			
				|  |  |          for (Fault f : faults) {
 | 
	
		
			
				|  |  | -            writeOneSimOneFault(s, null, f);
 | 
	
		
			
				|  |  | +            writeOneSimOneFault(seat, sim, null, f);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    public void writeOneSimOneFault(Sim s, RealExamFault ref, Fault f) {
 | 
	
		
			
				|  |  | -        l.info("下发故障:getSimId = {},fault.getName = {}", s.getSimId(), f.getName());
 | 
	
		
			
				|  |  | +    public void writeOneSimOneFault(Seat seat, Sim sim, RealExamFault ref, Fault f) {
 | 
	
		
			
				|  |  | +        l.info("下发故障:getSimId = {},fault.getName = {}", sim.getSimId(), f.getName());
 | 
	
		
			
				|  |  |          // todo:ref is null.
 | 
	
		
			
				|  |  |          // 下发故障
 | 
	
		
			
				|  |  | -        SimMsg smA1 = commBuildService.buildSendMsgWriteFault(s.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | -        SimMsg smA2 = send(smA1, s, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | +        SimMsg smA1 = commBuildService.buildSendMsgWriteFault(sim.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | +        SimMsg smA2 = send(smA1, seat, sim, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 开始考试前检查读取。
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param sim
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public AjaxResult readOneSimAllFaultCheck(Sim s) {
 | 
	
		
			
				|  |  | +    public AjaxResult readOneSimAllFaultCheck(Seat seat, Sim sim) {
 | 
	
		
			
				|  |  |          Fault q = new Fault();
 | 
	
		
			
				|  |  |          q.setFaultType(Fault.Type.REAL_GZBW);
 | 
	
		
			
				|  |  | -        q.setSimType(s.getSimType());
 | 
	
		
			
				|  |  | +        q.setSimType(sim.getSimType());
 | 
	
		
			
				|  |  |          List<Fault> list = faultService.selectFaultList(q);
 | 
	
		
			
				|  |  |          List<Fault> listNG = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (Fault f : list) {
 | 
	
		
			
				|  |  | -            AjaxResult ar = readOneSimOneFaultCheck(s, f);
 | 
	
		
			
				|  |  | +            AjaxResult ar = readOneSimOneFaultCheck(seat, sim, f);
 | 
	
		
			
				|  |  |              if (ar.isError()) {
 | 
	
		
			
				|  |  |                  listNG.add(f);
 | 
	
		
			
				|  |  |                  l.info("故障部位[" + f.getBindHardwareMsg() + "][" + f.getReplaceName() + "]未正确安装;");
 | 
	
	
		
			
				|  | @@ -691,15 +640,15 @@ public class CommSendService {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 检查读取。
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param sim
 | 
	
		
			
				|  |  |       * @param f
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public AjaxResult readOneSimOneFaultCheck(Sim s, Fault f) {
 | 
	
		
			
				|  |  | -        l.info("readOneSimOneFaultCheck s = {},f = {}", s, f);
 | 
	
		
			
				|  |  | -        SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(s.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | -        SimMsg sm2 = send(sm1, s, RETRY_COUNT_CHECK_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | -        return simReceiveService.getOneFaultCheck(sm2, s, f);
 | 
	
		
			
				|  |  | +    public AjaxResult readOneSimOneFaultCheck(Seat seat, Sim sim, Fault f) {
 | 
	
		
			
				|  |  | +        l.info("readOneSimOneFaultCheck s = {},f = {}", sim, f);
 | 
	
		
			
				|  |  | +        SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(sim.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | +        SimMsg sm2 = send(sm1, seat, sim, RETRY_COUNT_CHECK_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | +        return simReceiveService.getOneFaultCheck(sm2, sim, f);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -711,91 +660,93 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          l.info("readOneSimAllFaultFirstTimeByExam re = {}", re);
 | 
	
		
			
				|  |  |          List<RealExamFault> list = realExamFaultService.listAllType2(re.getExamId());
 | 
	
		
			
				|  |  |          for (RealExamFault ref : list) {
 | 
	
		
			
				|  |  | -            Sim s = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  | +            Seat seat = seatService.selectSeatBySeatId(re.getSeatId());
 | 
	
		
			
				|  |  | +            Sim sim = simService.selectSimBySimId(re.getSimId());
 | 
	
		
			
				|  |  |              Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
 | 
	
		
			
				|  |  | -            readOneSimOneFaultFirstTime(s, ref, f, null);
 | 
	
		
			
				|  |  | +            readOneSimOneFaultFirstTime(seat, sim, ref, f, null);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 第一次读取,作为出题值。debug模式。
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param sim
 | 
	
		
			
				|  |  |       * @param faultIds
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public void readOneSimAllFaultFirstTimeBySim(Sim s, final String[] faultIds) {
 | 
	
		
			
				|  |  | -        l.info("readOneSimAllFaultFirstTimeBySim s = {}", s);
 | 
	
		
			
				|  |  | -        List<Fault> list = faultService.listType3(s.getSimType());
 | 
	
		
			
				|  |  | +    public void readOneSimAllFaultFirstTimeBySim(Seat seat, Sim sim, final String[] faultIds) {
 | 
	
		
			
				|  |  | +        l.info("readOneSimAllFaultFirstTimeBySim s = {}", sim);
 | 
	
		
			
				|  |  | +        List<Fault> list = faultService.listType3(sim.getSimType());
 | 
	
		
			
				|  |  |          for (Fault f : list) {
 | 
	
		
			
				|  |  | -            readOneSimOneFaultFirstTime(s, null, f, faultIds);
 | 
	
		
			
				|  |  | +            readOneSimOneFaultFirstTime(seat, sim, null, f, faultIds);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 第一次读取,作为出题值。
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param sim
 | 
	
		
			
				|  |  |       * @param ref      debug调试模式为空。可以为空。
 | 
	
		
			
				|  |  |       * @param f
 | 
	
		
			
				|  |  |       * @param faultIds debug调试模式为空。
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public void readOneSimOneFaultFirstTime(Sim s, RealExamFault ref, Fault f, String[] faultIds) {
 | 
	
		
			
				|  |  | +    public void readOneSimOneFaultFirstTime(Seat seat, Sim sim, RealExamFault ref, Fault f, String[] faultIds) {
 | 
	
		
			
				|  |  |          l.info("readOneSimOneFaultFirstTime");
 | 
	
		
			
				|  |  |          // 读取一次当前电阻代表值作为出题值。
 | 
	
		
			
				|  |  | -        SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(s.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | -        SimMsg sm2 = send(sm1, s, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | -        simReceiveService.setFaultQuestionValue(sm2, s, ref, f, faultIds);
 | 
	
		
			
				|  |  | +        SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(sim.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | +        SimMsg sm2 = send(sm1, seat, sim, RETRY_COUNT_WRITE_ONE_FAULT, SLEEP_LONG);
 | 
	
		
			
				|  |  | +        simReceiveService.setFaultQuestionValue(sm2, sim, ref, f, faultIds);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug读取一个故障位置数据
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @param bindHardwareMsg
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  | -     * @throws IOException
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public SimMsg debugReadOneFaultResistance(final String simNum, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  | -        SimMsg sm = commBuildService.buildSendMsgReadFaultResistance(simNum, bindHardwareMsg);
 | 
	
		
			
				|  |  | -        return send(sm, null, RETRY_COUNT_0, SLEEP_SHORT);
 | 
	
		
			
				|  |  | +    public SimMsg debugReadOneFaultResistance(final Long seatId, final String bindHardwareMsg) {
 | 
	
		
			
				|  |  | +        Seat seat = seatService.selectSeatBySeatId(seatId);
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  | +        SimMsg sm = commBuildService.buildSendMsgReadFaultResistance(sim.getSimNum(), bindHardwareMsg);
 | 
	
		
			
				|  |  | +        return send(sm, seat, null, RETRY_COUNT_0, SLEEP_SHORT);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * debug读取全部故障位置数据
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param simNum
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  | -     * @throws IOException
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public List<SimMsg> debugReadAllFaultResistance(final String simNum) {
 | 
	
		
			
				|  |  | +    public List<SimMsg> debugReadAllFaultResistance(final Long seatId) {
 | 
	
		
			
				|  |  | +        Sim sim = gggSimBySeatId(seatId);
 | 
	
		
			
				|  |  |          List<SimMsg> list = new ArrayList<>();
 | 
	
		
			
				|  |  | -        String simType = simService.uniqueBySimNum(simNum).getSimType();
 | 
	
		
			
				|  |  | +        String simType = simService.uniqueBySimNum(sim.getSimNum()).getSimType();
 | 
	
		
			
				|  |  |          for (String b : getGZBWBySimType(simType)) {
 | 
	
		
			
				|  |  | -            list.add(debugReadOneFaultResistance(simNum, b));
 | 
	
		
			
				|  |  | +            list.add(debugReadOneFaultResistance(seatId, b));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return list;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * @param s
 | 
	
		
			
				|  |  | +     * @param sim
 | 
	
		
			
				|  |  |       * @param reF
 | 
	
		
			
				|  |  |       * @param f
 | 
	
		
			
				|  |  |       * @param refState 中间轮询是null,交卷最后一次读取为finish状态。用来修改状态的。debug模式下执行为null。
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public void readOneSimOneFaultResistance(Sim s, RealExamFault reF, Fault f, String refState) {
 | 
	
		
			
				|  |  | +    public void readOneSimOneFaultResistance(Seat seat, Sim sim, RealExamFault reF, Fault f, String refState) {
 | 
	
		
			
				|  |  |          l.info("readOneSimOneFaultResistance");
 | 
	
		
			
				|  |  | -        SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(s.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  | +        SimMsg sm1 = commBuildService.buildSendMsgReadFaultResistance(sim.getSimNum(), f.getBindHardwareMsg());
 | 
	
		
			
				|  |  |          SimMsg sm2 = null;
 | 
	
		
			
				|  |  |          if (reF != null && refState != null) {
 | 
	
		
			
				|  |  |              if (RealExamFault.State.FINISH.equals(refState)) { // 是否最后一次读取。
 | 
	
		
			
				|  |  | -                sm2 = send(sm1, s, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
 | 
	
		
			
				|  |  | +                sm2 = send(sm1, seat, sim, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                sm2 = send(sm1, s, RETRY_COUNT_0, SLEEP_SHORT);
 | 
	
		
			
				|  |  | +                sm2 = send(sm1, seat, sim, RETRY_COUNT_0, SLEEP_SHORT);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            sm2 = send(sm1, s, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
 | 
	
		
			
				|  |  | +            sm2 = send(sm1, seat, sim, RETRY_COUNT_READ_ONE_RESISTANCE, SLEEP_SHORT);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        simReceiveService.setFaultAnswerValue(sm2, s, reF, f, refState);
 | 
	
		
			
				|  |  | +        simReceiveService.setFaultAnswerValue(sm2, sim, reF, f, refState);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private long previousSendSleep = 0;
 | 
	
	
		
			
				|  | @@ -804,12 +755,13 @@ public class CommSendService {
 | 
	
		
			
				|  |  |       * send hex message
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @param sm              发送
 | 
	
		
			
				|  |  | -     * @param s               可以为空,更新最后发送/接收时间 用。
 | 
	
		
			
				|  |  | +     * @param seat            不能为空
 | 
	
		
			
				|  |  | +     * @param sim             可以为空!更新最后发送/接收时间 用。
 | 
	
		
			
				|  |  |       * @param retryTotalCount 重试次数
 | 
	
		
			
				|  |  |       * @param sleep           不使用传入0,不进行挂起。
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public synchronized SimMsg send(final SimMsg sm, final Sim s, final int retryTotalCount, final long sleep) {
 | 
	
		
			
				|  |  | +    public synchronized SimMsg send(final SimMsg sm, final Seat seat, final Sim sim, final int retryTotalCount, final long sleep) {
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              if (!config.isCommGlobal()) {
 | 
	
		
			
				|  |  |                  l.warn("isCommGlobal == false [模拟器通信被禁用!]");
 | 
	
	
		
			
				|  | @@ -818,6 +770,10 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              if (sm == null || sm.getSendMsg() == null || StringUtils.isBlank(sm.getSendMsg())) {
 | 
	
		
			
				|  |  |                  throw new IllegalArgumentException("SimMsg IllegalArgument");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            // sim
 | 
	
		
			
				|  |  | +            if (seat == null) {
 | 
	
		
			
				|  |  | +                throw new IllegalArgumentException("seat is null");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              if (sleep < 0) {
 | 
	
		
			
				|  |  |                  throw new IllegalArgumentException("SimMsg sleep");
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -826,21 +782,25 @@ public class CommSendService {
 | 
	
		
			
				|  |  |                  l.info("####SendMsg#### == [{}]", sm);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 如果没有打开socket,顺道打开。正好后面要sleep
 | 
	
		
			
				|  |  | -            socketOldService.openSocket();
 | 
	
		
			
				|  |  | +            // SocketOldService实现
 | 
	
		
			
				|  |  | +            // socketOldService.openSocket();
 | 
	
		
			
				|  |  | +            socketService.openOne(seat.toSimSocketVo());
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                // sleep ,追求顺序请求。
 | 
	
		
			
				|  |  | +                // sleep挂起线程,追求顺序请求。
 | 
	
		
			
				|  |  |                  if (sleep > 0 && previousSendSleep != 0L) {
 | 
	
		
			
				|  |  |                      Thread.sleep(previousSendSleep);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              previousSendSleep = sleep;
 | 
	
		
			
				|  |  | -            Socket socket = socketOldService.getCachedSocket();
 | 
	
		
			
				|  |  | +            // SocketOldService实现
 | 
	
		
			
				|  |  | +            // Socket socket = socketOldService.getCachedSocket();
 | 
	
		
			
				|  |  | +            Socket socket = socketService.get(seat);
 | 
	
		
			
				|  |  |              InputStream is = socket.getInputStream();
 | 
	
		
			
				|  |  |              OutputStream os = socket.getOutputStream();
 | 
	
		
			
				|  |  |              os.write(hexStrToByteArrs(sm.getSendMsg()));
 | 
	
		
			
				|  |  |              sm.setSendTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | -            if (s != null) {
 | 
	
		
			
				|  |  | -                simService.updateLastSentTime(s);
 | 
	
		
			
				|  |  | +            if (sim != null) {
 | 
	
		
			
				|  |  | +                simService.updateLastSentTime(sim);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              byte[] buffer = new byte[LENGTH_24];
 | 
	
		
			
				|  |  |              int length = is.read(buffer);
 | 
	
	
		
			
				|  | @@ -849,6 +809,7 @@ public class CommSendService {
 | 
	
		
			
				|  |  |                  sbHex.append(String.format("%02X", buffer[i]));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              String receiveWith0 = sbHex.toString();
 | 
	
		
			
				|  |  | +            // 原始带0的收到报文。
 | 
	
		
			
				|  |  |              sm.setReceiveOriginalMsg(receiveWith0);
 | 
	
		
			
				|  |  |              sm.setReceiveMsg(commReceiveService.removeRrefix0(receiveWith0));
 | 
	
		
			
				|  |  |              sm.setReceiveTime(DateUtils.getNowDate());
 | 
	
	
		
			
				|  | @@ -864,17 +825,23 @@ public class CommSendService {
 | 
	
		
			
				|  |  |                      return sm;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if (s != null) {
 | 
	
		
			
				|  |  | -                simService.updateLastReceivedTime(s);
 | 
	
		
			
				|  |  | +            if (sim != null) {
 | 
	
		
			
				|  |  | +                simService.updateLastReceivedTime(sim);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          } catch (InterruptedException | IOException e) {   // SocketTimeoutException
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  |              // 失败计数
 | 
	
		
			
				|  |  | -            l.info("fail sim data = {}", s);
 | 
	
		
			
				|  |  | -            boolean limit = socketOldService.commFailCountAdd1(Objects.requireNonNull(s).getSimId());
 | 
	
		
			
				|  |  | -            if (limit) {
 | 
	
		
			
				|  |  | -                simService.updateSimStateBySimId(s.getSimId(), Sim.State.OFFLINE);
 | 
	
		
			
				|  |  | -                socketOldService.commFailCountClearOne(s.getSimId());
 | 
	
		
			
				|  |  | +            l.info("fail sim data = {}", sim);
 | 
	
		
			
				|  |  | +            // SocketOldService实现
 | 
	
		
			
				|  |  | +            // boolean limit = socketOldService.commFailCountAdd1(Objects.requireNonNull(sim).getSimId());
 | 
	
		
			
				|  |  | +            SimSocketVo ssv = seat.toSimSocketVo();
 | 
	
		
			
				|  |  | +            failedCountService.plus1(ssv);
 | 
	
		
			
				|  |  | +            if (failedCountService.isReachedMax(ssv, retryTotalCount)) {
 | 
	
		
			
				|  |  | +                // 达到重试次数上限,认为模拟器离线
 | 
	
		
			
				|  |  | +                simService.updateSimStateBySimId(sim.getSimId(), Sim.State.OFFLINE);
 | 
	
		
			
				|  |  | +                // SocketOldService实现
 | 
	
		
			
				|  |  | +                // socketOldService.commFailCountClearOne(sim.getSimId());
 | 
	
		
			
				|  |  | +                failedCountService.reset0(ssv);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 先考虑一台模拟器演示。
 | 
	
		
			
				|  |  |              // 进行重试 start
 | 
	
	
		
			
				|  | @@ -884,13 +851,14 @@ public class CommSendService {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (sm.getRetryCount() < retryTotalCount) {
 | 
	
		
			
				|  |  |                  sm.retryCountPlus1();
 | 
	
		
			
				|  |  | -                send(sm, s, retryTotalCount, sleep);
 | 
	
		
			
				|  |  | +                send(sm, seat, sim, retryTotalCount, sleep);
 | 
	
		
			
				|  |  |                  l.warn("####RetryTotalCount重试#### = {}", sm);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  l.warn("####RetryTotalCount达到重试上限#### = {}", sm);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 进行重试 end
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        // 最后返回报文实体。
 | 
	
		
			
				|  |  |          return sm;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -907,28 +875,6 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          return null;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * 等同于ping命令。
 | 
	
		
			
				|  |  | -     *
 | 
	
		
			
				|  |  | -     * @param ipV4
 | 
	
		
			
				|  |  | -     * @return
 | 
	
		
			
				|  |  | -     * @throws IOException
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    public boolean isReachable(String ipV4) {
 | 
	
		
			
				|  |  | -        InetAddress ia = null;
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | -            ia = InetAddress.getByName(ipV4);
 | 
	
		
			
				|  |  | -            return ia.isReachable(2048);
 | 
	
		
			
				|  |  | -        } catch (UnknownHostException e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  | -            return false;
 | 
	
		
			
				|  |  | -        } catch (IOException e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  | -            return false;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * https://mvnrepository.com/artifact/com.infiniteautomation/modbus4j/3.0.3
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -980,4 +926,21 @@ public class CommSendService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return hexString.toString();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * todo:不存在部分数据
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param seatId
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public Sim gggSimBySeatId(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);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("error gggSimBySeatId");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |