| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.zy.asrs.domain.param.CreateLocMoveTaskParam; |
| | | import com.zy.asrs.entity.BasShuttleOpt; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasShuttleOptService; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.ExecuteSupport; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.NavigateMapUtils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.common.utils.ShuttleOperaUtils; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.dispatcher.ShuttleDispatchUtils; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | @Component |
| | | public class ShuttleAction { |
| | |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private NavigateMapUtils navigateMapUtils; |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private ShuttleDispatchUtils shuttleDispatchUtils; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | public synchronized boolean assignWork(Integer shuttleNo, ShuttleAssignCommand assignCommand) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | |
| | | } |
| | | |
| | | targetLoc = locMast; |
| | | break; |
| | | } |
| | | |
| | | if(targetLoc == null) { |
| | | return; |
| | | } |
| | | |
| | | shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleNo); |
| | | shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleProtocol.getShuttleNo()); |
| | | } |
| | | |
| | | public synchronized void demoModeCargoMove() { |
| | | Config demoCargoMoveConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoCargoMove")); |
| | | if (demoCargoMoveConfig == null) { |
| | | return; |
| | | } |
| | | |
| | | if (!demoCargoMoveConfig.getValue().equals("Y")) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Config demoRunLevConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoRunLev")); |
| | | if (demoRunLevConfig == null) { |
| | | return; |
| | | } |
| | | List<Integer> levList = JSON.parseArray(demoRunLevConfig.getValue(), Integer.class); |
| | | Random random = new Random(); |
| | | int index = random.nextInt(levList.size()); |
| | | Integer lev = levList.get(index); |
| | | |
| | | //获取楼层小车数量 |
| | | int shuttleCountByLev = shuttleDispatchUtils.getShuttleCountByLev(lev); |
| | | //获取楼层货物搬运任务 |
| | | int currentLevTask = 0; |
| | | for (WrkMast wrkMast : wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("io_type", WrkIoType.LOC_MOVE.id))) { |
| | | if (Utils.getLev(wrkMast.getLocNo()) == lev) { |
| | | currentLevTask += 1; |
| | | } |
| | | } |
| | | |
| | | //搬运任务数量超过小车数量,暂时不生成新任务 |
| | | if (currentLevTask > shuttleCountByLev) { |
| | | return; |
| | | } |
| | | |
| | | LocMast sourceLoc = null; |
| | | EntityWrapper<LocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("lev1", lev); |
| | | wrapper.eq("loc_sts", "F"); |
| | | wrapper.last("ORDER BY RAND() LIMIT 1"); |
| | | for (int i = 0; i < 3; i++) { |
| | | LocMast locMast = locMastService.selectOne(wrapper); |
| | | if(locMast == null) { |
| | | continue; |
| | | } |
| | | |
| | | sourceLoc = locMast; |
| | | break; |
| | | } |
| | | |
| | | if(sourceLoc == null) { |
| | | return; |
| | | } |
| | | |
| | | LocMast targetLoc = null; |
| | | EntityWrapper<LocMast> targetWrapper = new EntityWrapper<>(); |
| | | targetWrapper.eq("lev1", lev); |
| | | targetWrapper.eq("loc_sts", "O"); |
| | | targetWrapper.last("ORDER BY RAND() LIMIT 1"); |
| | | for (int i = 0; i < 3; i++) { |
| | | LocMast locMast = locMastService.selectOne(targetWrapper); |
| | | if(locMast == null) { |
| | | continue; |
| | | } |
| | | |
| | | targetLoc = locMast; |
| | | break; |
| | | } |
| | | |
| | | if(targetLoc == null) { |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | CreateLocMoveTaskParam param = new CreateLocMoveTaskParam(); |
| | | param.setSourceLocNo(sourceLoc.getLocNo()); |
| | | param.setLocNo(targetLoc.getLocNo()); |
| | | param.setTaskPri(13); |
| | | |
| | | boolean result = commonService.createLocMoveTask(param); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // //跑库程序 |