| 
					
				 | 
			
			
				@@ -7,8 +7,11 @@ import cn.ele6.catalyzer.ruoyi.vue.custom.Ele6RYBaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.ele6.catalyzer.ruoyi.vue.enhance.TableDataInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.core.domain.AjaxResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.sim.controller.RealExamCollectionController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.sim.domain.vo.RealExamCollectionVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.context.annotation.Lazy; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -102,6 +105,8 @@ public class RealExamCollectionService extends Ele6RYBaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // -------------------------------- tom add  -------------------------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final Logger l = LoggerFactory.getLogger(RealExamCollectionService.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * [教师][分页]查询考试集合列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -281,43 +286,36 @@ public class RealExamCollectionService extends Ele6RYBaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * [教师]打开考试/练习集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * [教师]打开考试/训练集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param examCollectionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param examCollectionId   考试集合Id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param examCollectionType 考试集合类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public AjaxResult open(final Long examCollectionId, final String examCollectionType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        l.debug("open examCollectionId= {}", examCollectionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        l.debug("open examCollectionType= {}", examCollectionType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // check 1:检查id有效。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         RealExamCollection rec = selectRealExamCollectionByExamCollectionId(examCollectionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (rec == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return AjaxResult.error("考试集合不存在!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Check:检查Id有效。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (rec == null || rec.getExamCollectionId() == 0L) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("考试集合Id不存在!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            l.debug("rec = {}", rec); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        l.debug("rec = {}", rec); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // check 2:检查考试集合类型对应。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            final String dbType = rec.getExamCollectionType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            if (!StringUtils.equals(dbType, examCollectionType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                return AjaxResult.error("考试集合类型不对应!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // check 3:唯一open检查。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        if (existOpened()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            return AjaxResult.error("已经有打开的考试或者练习!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // check datetime todo:时间到了 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // do. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 自然人电子税务局 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 年报 多次  汇总表   12366 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Check:检查考试集合类型对应。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            final String dbType = rec.getExamCollectionType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!StringUtils.equals(dbType, examCollectionType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("考试集合类型不对应!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Check:检查是否已经打开。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.equals(rec.getExamCollectionState(), RealExamCollection.State.OPENED)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("已经打开!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         switch (examCollectionType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case RealExamCollection.Type.EXERCISE: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (existOpenedByType(RealExamCollection.Type.EXAM)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -338,26 +336,24 @@ public class RealExamCollectionService extends Ele6RYBaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case RealExamCollection.Type.EXAM: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                closeAllByType(RealExamCollection.Type.EXERCISE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                closeAllByType(RealExamCollection.Type.SELF_EXERCISE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (existOpenedByType(RealExamCollection.Type.EXERCISE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    closeAllByType(RealExamCollection.Type.EXERCISE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (existOpenedByType(RealExamCollection.Type.SELF_EXERCISE)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    closeAllByType(RealExamCollection.Type.SELF_EXERCISE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 closeAllExcludeIdByType(RealExamCollection.Type.EXAM, rec.getExamCollectionId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("考试集合类型错误!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // Step 4:尝试打开所有Socket,提前准备,允许有打开失败的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // SocketOldService实现。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // AjaxResult ar1 = socketOldService.openSocket(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Step:尝试打开所有Socket,提前准备,允许有打开失败的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         AjaxResult ar1 = socketService.tryOpenAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (ar1.isError()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return ar1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            l.info("AjaxResult = {}", ar1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 更新相关数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // Step :修改考试集合状态。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Step:修改考试集合状态。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             rec.setExamCollectionState(RealExamCollection.State.OPENED); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             updateRealExamCollection(rec); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -365,6 +361,45 @@ public class RealExamCollectionService extends Ele6RYBaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return AjaxResult.success("开启成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * [教师]关闭考试/训练集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param examCollectionId   考试集合Id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param examCollectionType 考试集合类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxResult close(final Long examCollectionId, final String examCollectionType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RealExamCollection rec = selectRealExamCollectionByExamCollectionId(examCollectionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Check:检查Id有效。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (rec == null || rec.getExamCollectionId() == 0L) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("考试集合Id不存在!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            l.debug("rec = {}", rec); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Check:检查考试集合类型对应。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            final String dbType = rec.getExamCollectionType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!StringUtils.equals(dbType, examCollectionType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("考试集合类型不对应!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Check:检查是否已经关闭。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.equals(rec.getExamCollectionState(), RealExamCollection.State.CLOSED)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return AjaxResult.error("已经关闭!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // todo:是否还有正在进行的考试 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 修改为socket常开,直接返回成功结果。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Step:修改考试集合状态。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rec.setExamCollectionState(RealExamCollection.State.CLOSED); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateRealExamCollection(rec); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return AjaxResult.success("关闭成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<RealExamCollection> listAllByType(String examCollectionType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         RealExamCollection q = new RealExamCollection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         q.setExamCollectionType(examCollectionType); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -398,28 +433,6 @@ public class RealExamCollectionService extends Ele6RYBaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * [教师]关闭考试/练习集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param examCollectionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public AjaxResult close(final Long examCollectionId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // check 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // todo:是否还有正在进行的考试 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        RealExamCollection f = selectRealExamCollectionByExamCollectionId(examCollectionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 修改考试集合状态。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            f.setExamCollectionState(RealExamCollection.State.CLOSED); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateRealExamCollection(f); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 关闭socket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 修改为socket常开,直接返回成功结果。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // return commSendService.closeSocket(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return AjaxResult.success("关闭连接成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public AjaxResult closeAll() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // SocketOldService实现 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // return socketOldService.closeSocket(); 
			 |