|
@@ -6,6 +6,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
@@ -121,22 +122,34 @@ public class CommSendService {
|
|
|
}
|
|
|
|
|
|
public void readAll() {
|
|
|
- List<RealExam> listRE = realExamService.listAllStatusAnswering();
|
|
|
+ List<RealExam> listRE = realExamService.listAllStatus(RealExam.STATE_ANSWERING);
|
|
|
listRE.forEach(e -> {
|
|
|
if (e == null) {
|
|
|
return;
|
|
|
}
|
|
|
- List<RealExamFault> listREF = realExamFaultService.listAllStatusLoopRead(e.getExamId());
|
|
|
+ List<RealExamFault> listREF = realExamFaultService.listAllType2YesLoopReadState(e.getExamId());
|
|
|
listREF.forEach(ref -> {
|
|
|
Sim s = simService.selectSimBySimId(e.getSimId());
|
|
|
Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
|
|
|
- readOneFaultResistance(s, ref, f);
|
|
|
+ if (f != null &&
|
|
|
+ f.getFaultType().equals(Fault.TYPE_3) &&
|
|
|
+ f.getFaultState().equals(Fault.STATE_ENABLE)
|
|
|
+ )
|
|
|
+ readOneFaultResistance(s, ref, f);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Async version.
|
|
|
+ */
|
|
|
+ @Async("tp-comm")
|
|
|
+ public void readAllAsync() {
|
|
|
+ readAll();
|
|
|
+ }
|
|
|
+
|
|
|
public void readOneExamAtLast(RealExam re) {
|
|
|
- List<RealExamFault> listREF = realExamFaultService.listAllStatusLoopRead(re.getExamId());
|
|
|
+ List<RealExamFault> listREF = realExamFaultService.listAllType2YesLoopReadState(re.getExamId());
|
|
|
listREF.forEach(ref -> {
|
|
|
Sim s = simService.selectSimBySimId(re.getSimId());
|
|
|
Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
|
|
@@ -162,6 +175,11 @@ public class CommSendService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Async()
|
|
|
+ public void checkAllSimStateAsync() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public void checkOneSimState(Sim s) {
|
|
|
l.info(s.toString());
|
|
|
// check todo:
|
|
@@ -182,7 +200,7 @@ public class CommSendService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * prepare one exam.
|
|
|
+ * 清除一个考试的,对应的某型号一台模拟器的,所有设备故障。
|
|
|
*
|
|
|
* @param re
|
|
|
*/
|
|
@@ -192,9 +210,13 @@ public class CommSendService {
|
|
|
|
|
|
}
|
|
|
//
|
|
|
- List<RealExamFault> list = realExamFaultService.listAllStateInitByExamId(re.getExamId());
|
|
|
+ List<RealExamFault> list = realExamFaultService.listAllType2InitStateByExamId(re.getExamId());
|
|
|
list.forEach(ref -> {
|
|
|
Fault f = faultService.selectFaultByFaultId(ref.getFaultId());
|
|
|
+ if (faultService.isDisable(f.getFaultId())) {
|
|
|
+ l.warn("故障{}-Disable", ref.getFaultId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
l.info("f.toString() = " + f.toString());
|
|
|
Sim s = simService.selectSimBySimId(re.getSimId());
|
|
|
l.info("s.toString() = " + s.toString());
|
|
@@ -206,6 +228,16 @@ public class CommSendService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Async version.
|
|
|
+ *
|
|
|
+ * @param re
|
|
|
+ */
|
|
|
+ @Async("tp-comm")
|
|
|
+ public void clearListFaultByRealExamAsync(RealExam re) {
|
|
|
+ clearListFaultByRealExam(re);
|
|
|
+ }
|
|
|
+
|
|
|
public void clearAll() {
|
|
|
// todo:
|
|
|
simService.listAllEnable().forEach(s -> {
|
|
@@ -246,7 +278,7 @@ public class CommSendService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void writeOneFault(Sim s, RealExamFault reF, Fault f) {
|
|
|
+ public void writeOneFault(Sim s, RealExamFault ref, Fault f) {
|
|
|
try {
|
|
|
// 下发故障
|
|
|
SimMsg sm1 = new SimMsg();
|
|
@@ -262,10 +294,10 @@ public class CommSendService {
|
|
|
sm2.setSendMsg(sendMsg2);
|
|
|
String receiveMsg2 = send(sendMsg2, s);
|
|
|
sm2.setReceiveMsg(receiveMsg2);
|
|
|
- simReceiveService.setFaultQuestionValue(sm2, s, reF, f);
|
|
|
+ simReceiveService.setFaultQuestionValue(sm2, s, ref, f);
|
|
|
// 修改关联状态。
|
|
|
{
|
|
|
- RealExamFault f1 = realExamFaultService.selectRealExamFaultByRefId(reF.getRefId());
|
|
|
+ RealExamFault f1 = realExamFaultService.selectRealExamFaultByRefId(ref.getRefId());
|
|
|
f1.setRefState(RealExamFault.REF_STATE_LOOP_READ);
|
|
|
realExamFaultService.updateRealExamFault(f1);
|
|
|
}
|