| | |
| | | log.info(agv.getUuid() + "号AGV不可用,已经存在进行中的任务..."); |
| | | return R.error(); |
| | | } |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | // zhangc 在用户手动控制时,需要用户主观判断,所以小车只要高于低电量阈值就可以手动控制,所以注释 |
| | | if (!agvService.judgeEnable(agv.getId(),true,true)) { |
| | | log.info(agv.getUuid() + "号AGV不可用,任务无法计算..."); |
| | | return R.error(); |
| | | } |
| | | |
| | | |
| | | // generate |
| | | Loc oriLoc = null; |
| | |
| | | if (null == endCode) { |
| | | return R.error(); |
| | | } |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null)) { |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null, true)) { |
| | | return R.error(); |
| | | } |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), null, null)) { |
| | | if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), null, null, true)) { |
| | | return R.error(); |
| | | } |
| | | break; |
| | |
| | | continue; |
| | | } |
| | | |
| | | mainLockWrapService.buildMinorTask(agv.getId(), TaskTypeType.TO_CHARGE, null, null); |
| | | mainLockWrapService.buildMinorTask(agv.getId(), TaskTypeType.TO_CHARGE, null, null,false); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | // } |
| | | |
| | | mainLockWrapService.buildMinorTask(agv.getId(), TaskTypeType.TO_STANDBY, null, null); |
| | | mainLockWrapService.buildMinorTask(agv.getId(), TaskTypeType.TO_STANDBY, null, null,false); |
| | | } |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | // 2. in idle status |
| | | if (!agvService.judgeEnable(agv.getId(), true)) { |
| | | if (!agvService.judgeEnable(agv.getId(), true,false)) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam) { |
| | | public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam, Boolean force) { |
| | | boolean lockAcquired = false; |
| | | try { |
| | | if (!(lockAcquired = this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS))) { |
| | |
| | | } |
| | | // log.info("buildMinorTask AGV[{}] lock time: {}", agv.getUuid(), System.currentTimeMillis()); |
| | | |
| | | return mainService.buildMinorTask(agvId, taskType, destination, jam); |
| | | return mainService.buildMinorTask(agvId, taskType, destination, jam,force); |
| | | } catch (Exception e) { |
| | | log.error("MainLockWrapService.buildMinorTask[task]", e); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | |
| | | try { |
| | | // valid ----------------------------------------------- |
| | | Agv agv = agvService.getById(agvId); |
| | | if (!agvService.judgeEnable(agv.getId(), false)) { |
| | | if (!agvService.judgeEnable(agv.getId(), false, false)) { |
| | | return; |
| | | } |
| | | if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) { |
| | |
| | | |
| | | /** |
| | | * 充电 回待机位任务 |
| | | * zc 新增了是否强制,强制说明由用户发起,小车在超过低电量就可以做移动充电去待机位 |
| | | */ |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) // although there is a Transactional here that the lock is isolated, but we can't join the caller's Transactional |
| | | public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam) { |
| | | public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam,boolean force) { |
| | | if (Cools.isEmpty(agvId, taskType)) { return false; } |
| | | try { |
| | | String agvNo = agvService.getAgvNo(agvId); |
| | | if (!agvService.judgeEnable(agvId)) { |
| | | if (!agvService.judgeEnable(agvId,false, force)) { |
| | | return false; |
| | | } |
| | | if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) { |
| | |
| | | return; |
| | | } |
| | | |
| | | if (mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, destinationCodeData, null)) { |
| | | if (mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, destinationCodeData, null,false)) { |
| | | log.info( "{}开始作业演示...", agvNo); |
| | | |
| | | CoreCache.AGV_MOCK_STEP_CACHE.put(agvId, CodeStepDto.build(destinationCodeData, jobType)); |
| | |
| | | if (Cools.isEmpty(destinationCodeData)) { |
| | | return; |
| | | } |
| | | if (mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, destinationCodeData, null)) { |
| | | if (mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, destinationCodeData, null,false)) { |
| | | log.info( "{}开始走行演示...", agvNo); |
| | | } |
| | | } |
| | |
| | | |
| | | } else { |
| | | |
| | | return mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, endCodeData, jam); |
| | | return mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, endCodeData, jam, false); |
| | | } |
| | | |
| | | return true; |
| | |
| | | |
| | | Boolean judgeEnable(Long agvId); |
| | | |
| | | Boolean judgeEnable(Long agvId, Boolean withBattery); |
| | | Boolean judgeEnable(Long agvId, Boolean withBattery, Boolean force); |
| | | |
| | | Boolean judgeOnline(Long agvId); |
| | | |
| | |
| | | |
| | | @Override |
| | | public Boolean judgeEnable(Long agvId) { |
| | | return this.judgeEnable(agvId, false); |
| | | return this.judgeEnable(agvId, false,false); |
| | | } |
| | | |
| | | /** |
| | | * 判断AGV是否可用 |
| | | * @param agvId |
| | | * @param isLowBattery 低电量判断 |
| | | * @param force 是否强制操作 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Boolean judgeEnable(Long agvId, Boolean isLowBattery) { |
| | | public Boolean judgeEnable(Long agvId, Boolean isLowBattery, Boolean force) { |
| | | String agvNo = this.getAgvNo(agvId); |
| | | AgvModel agvModel = agvModelService.getByAgvId(agvId); |
| | | if (0 < segmentService.count(new LambdaQueryWrapper<Segment>() |
| | |
| | | return false; |
| | | } |
| | | if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) { |
| | | if (agvDetail.getVol() < agvModel.getQuaBattery()) { |
| | | return false; |
| | | if (force){ |
| | | if (agvDetail.getVol() < agvModel.getLowBattery()) { |
| | | return false; |
| | | } |
| | | }else { |
| | | if (agvDetail.getVol() < agvModel.getQuaBattery()) { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | if (!agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Boolean judgeOnline(Long agvId) { |
| | | Agv agv = this.getById(agvId); |