| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private static final String PROJECT_DEPT_WEIGHT = ":PROJECT_DEPT_WEIGHT"; |
| | | // 保洁员权重标识 |
| | | private static final String CLEANER_WEIGHT = ":CLEANER_WEIGHT"; |
| | | // 重复点位标识 |
| | | private static final String REPEAT_LOCATION = ":REPEAT_LOCATION"; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | |
| | | // 创建任务 |
| | | list.forEach(detail -> { |
| | | // 计算周期 |
| | | long cycle = detail.getCycle(); |
| | | int cycle = detail.getCycle(); |
| | | switch (detail.getCycleType()){ |
| | | case 2: |
| | | cycle = cycle * 7; |
| | |
| | | .in(TCleaner::getProjectId, areaIds)); |
| | | int cleanerSums = num1 * Integer.parseInt(count + ""); |
| | | // 获取每天需要抽取的保洁员数,向上取整 |
| | | int dayCleanerCount = cleanerSums / detail.getCycle(); |
| | | int dayCleanerCount = cleanerSums / cycle; |
| | | |
| | | // 获取保洁员权重 |
| | | List<String> cleanerIds = redisCache.getCacheList(detail.getId() + CLEANER_WEIGHT); |
| | |
| | | } |
| | | } |
| | | |
| | | // TODO 抽取重复点位 |
| | | // 抽取重复点位 |
| | | Integer currentValue = detail.getCurrentValue(); |
| | | if(currentValue != cycle){ |
| | | // 周期天数加一 |
| | | detail.setCurrentValue(currentValue + 1); |
| | | // 获取重复点位 |
| | | Set<TLocation> repeatLocation = redisCache.getCacheSet(detail.getId() + REPEAT_LOCATION); |
| | | if(!CollectionUtils.isEmpty(repeatLocation)){ |
| | | List<TLocation> locations = randomSelection(new ArrayList<>(tLocationList), num3); |
| | | tLocationList.addAll(locations); |
| | | } |
| | | Set<TLocation> locationSet = new HashSet<>(tLocationList); |
| | | redisCache.setCacheSet(detail.getId() + REPEAT_LOCATION, locationSet); |
| | | |
| | | }else { |
| | | // 设置当前周期为0 |
| | | detail.setCurrentValue(0); |
| | | // 将重复点位置空 |
| | | redisCache.deleteObject(detail.getId() + REPEAT_LOCATION); |
| | | } |
| | | |
| | | // 创建任务 |
| | | List<TTask> tasks = new ArrayList<>(); |
| | |
| | | tasks.add(task); |
| | | } |
| | | taskCleanService.saveBatch(tasks); |
| | | |
| | | templateDetailService.updateById(detail); |
| | | }); |
| | | |
| | | } |