package com.zy.asrs.task; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.zy.asrs.entity.BasDevp; import com.zy.asrs.entity.WrkMast; import com.zy.asrs.service.BasDevpService; import com.zy.asrs.service.WrkMastService; import com.zy.asrs.task.handler.AutomaticLibraryTransferHandler; import com.zy.system.entity.Config; import com.zy.system.service.ConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class AutomaticLibraryTransferScheduler { @Autowired private ConfigService configService; @Autowired private WrkMastService wrkMastService; @Autowired private AutomaticLibraryTransferHandler automaticLibraryTransferHandler; @Autowired private BasDevpService basDevpService; @Scheduled(cron = "0/3 * * * * ? ") private void execute(){ Config config = configService.selectConfigByCode("AutomaticLibraryTransfer"); if(config.getStatus()==0){ return; } int WrkCount = wrkMastService.selectCount(new EntityWrapper()); if(WrkCount>0){ return; } //自动出满托200 Config configBoundShipment = configService.selectConfigByCode("AutomaticOutboundShipment"); //自动出空板100 Config configAutoEmpty = configService.selectConfigByCode("AutoEmpty"); BasDevp basDevp100 = basDevpService.selectOne(new EntityWrapper().eq("dev_no",100)); BasDevp basDevp200 = basDevpService.selectOne(new EntityWrapper().eq("dev_no",200)); if((configAutoEmpty.getStatus()==1&&!basDevp100.getLoading().equals("Y"))||(configBoundShipment.getStatus()==1&&!basDevp200.getLoading().equals("Y"))){ return; } if(config.getValue().equals("1")){ automaticLibraryTransferHandler.startOne(); }else if(config.getValue().equals("2")){ automaticLibraryTransferHandler.startTwo(); }else if(config.getValue().equals("3")){ automaticLibraryTransferHandler.startThree(); }else{ automaticLibraryTransferHandler.startAll(); } System.out.println("AutomaticLibraryTransferScheduler"); } }