|  |  |  | @ -19,6 +19,7 @@ import com.glxp.api.service.collect.IoCollectOrderService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.service.collect.IoCollectSetService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.IntUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  |  | import org.apache.commons.lang3.exception.ExceptionUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.slf4j.Logger; | 
			
		
	
		
			
				
					|  |  |  |  | import org.slf4j.LoggerFactory; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.BeanUtils; | 
			
		
	
	
		
			
				
					|  |  |  | @ -30,6 +31,7 @@ import org.springframework.stereotype.Component; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.concurrent.atomic.AtomicBoolean; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  |  | @Component | 
			
		
	
	
		
			
				
					|  |  |  | @ -49,9 +51,13 @@ public class AsyncIoCollectOrderFinishTask implements SchedulingConfigurer { | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCollectSetBustypeMapper ioCollectSetBustypeMapper; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     // 使用原子布尔值作为简单的锁机制
 | 
			
		
	
		
			
				
					|  |  |  |  |     private final AtomicBoolean isRunning = new AtomicBoolean(false); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { | 
			
		
	
		
			
				
					|  |  |  |  |         scheduledTaskRegistrar.addTriggerTask(() -> process(), | 
			
		
	
		
			
				
					|  |  |  |  |         scheduledTaskRegistrar.addTriggerTask(() -> processWithLock(), | 
			
		
	
		
			
				
					|  |  |  |  |                 triggerContext -> { | 
			
		
	
		
			
				
					|  |  |  |  |                     ScheduledRequest scheduledRequest = new ScheduledRequest(); | 
			
		
	
		
			
				
					|  |  |  |  |                     scheduledRequest.setCronName("ioCollectOrderFinishTask"); | 
			
		
	
	
		
			
				
					|  |  |  | @ -64,6 +70,23 @@ public class AsyncIoCollectOrderFinishTask implements SchedulingConfigurer { | 
			
		
	
		
			
				
					|  |  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private void processWithLock() { | 
			
		
	
		
			
				
					|  |  |  |  |         // 如果已经在运行,则跳过本次执行
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (!isRunning.compareAndSet(false, true)) { | 
			
		
	
		
			
				
					|  |  |  |  |             log.warn("上一次任务还在执行中,跳过本次执行"); | 
			
		
	
		
			
				
					|  |  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("开始执行订单下载任务"); | 
			
		
	
		
			
				
					|  |  |  |  |             process(); | 
			
		
	
		
			
				
					|  |  |  |  |         } finally { | 
			
		
	
		
			
				
					|  |  |  |  |             isRunning.set(false); | 
			
		
	
		
			
				
					|  |  |  |  |             log.info("订单下载任务执行完成"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoCollectSetService collectSetService; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -97,7 +120,7 @@ public class AsyncIoCollectOrderFinishTask implements SchedulingConfigurer { | 
			
		
	
		
			
				
					|  |  |  |  |                         try { | 
			
		
	
		
			
				
					|  |  |  |  |                             collectOrderService.finishOrder(collectOrderRequest, authAdmin, true); | 
			
		
	
		
			
				
					|  |  |  |  |                         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |                             log.error("自动完成第三方处方单异常", e); | 
			
		
	
		
			
				
					|  |  |  |  |                             log.error("自动完成第三方处方单异常", ExceptionUtils.getStackTrace(e)); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |