| 
					
				 | 
			
			
				@@ -0,0 +1,56 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.ruoyi.system.utils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.system.domain.PostCollectionsSystem; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.system.domain.vo.CollectionsVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.system.mapper.PostCollectionsSystemMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.system.service.IPostCollectionsSystemService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.context.annotation.Configuration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.scheduling.annotation.EnableScheduling; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.scheduling.annotation.Scheduled; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static com.ruoyi.common.utils.SecurityUtils.getUsername; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Configuration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@EnableScheduling 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class SpringTaskConfig { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PostCollectionsSystemMapper postCollectionsSystemMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IPostCollectionsSystemService postCollectionsSystemService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Scheduled(cron = "0/10 * * * * ?") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void cron() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date nowDate = DateUtils.getNowDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        PostCollectionsSystem postCollectionsSystem = new PostCollectionsSystem(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PostCollectionsSystem> postCollectionsSystemList = postCollectionsSystemMapper.selectPostCollectionsSystemList(postCollectionsSystem); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        postCollectionsSystemList = postCollectionsSystemList.stream().map((item)->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Date startTime = item.getStartTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Date endTime = item.getEndTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long type = item.getType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (null!=startTime && null!=endTime){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (nowDate.before(startTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.setType((long) 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else if (nowDate.after(endTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.setType((long) 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.setType((long) 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!type.equals(item.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                item.setUpdateBy(getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                item.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return item; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        postCollectionsSystemMapper.updateBatchById(postCollectionsSystemList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |