| | |
| | | List<BasAgv> idleAgvs = this.selectList(new EntityWrapper<BasAgv>() |
| | | .eq("in_enable", "Y") |
| | | .eq("is_user", 1) |
| | | .eq("status", 6) |
| | | .in("status", 6, 8 ,12) |
| | | ); |
| | | if (Cools.isEmpty(idleAgvs)) { |
| | | log.warn("没有空闲的Agv小车"); |
| | |
| | | return workNo; |
| | | } |
| | | |
| | | @Override |
| | | public String getEmptyAgvWorkNo() { |
| | | String workNo = null; |
| | | for (int i = 0; i < 10; i++) { |
| | | workNo = getEmptyRandom(); |
| | | int count = this.selectCount(new EntityWrapper<BasAgv>().eq("task_code", workNo)); |
| | | if (count == 0) { |
| | | break; |
| | | } |
| | | } |
| | | if (Cools.isEmpty(workNo)) { |
| | | throw new CoolException("下发AGV任务错误,工作号异常"); |
| | | } |
| | | return workNo; |
| | | } |
| | | |
| | | |
| | | private String getRandom() { |
| | | return String.format("%04d",new Random().nextInt(9999)); |
| | | return String.format("%04d",new Random().nextInt(6000)); |
| | | } |
| | | |
| | | public String getEmptyRandom(){ |
| | | int min = 6001; |
| | | int max = 9999; |
| | | Random random = new Random(); |
| | | int s = random.nextInt(max) % (max - min + 1) + min; |
| | | return String.format("%04d", s); |
| | | } |
| | | |
| | | } |