Commit c5cf607fa71586adf99d885e4a542530235ce9ee
1 parent
0a29b019
钥匙归还
Showing
3 changed files
with
30 additions
and
19 deletions
Bsth-admin/src/main/java/com/ruoyi/domain/scheduling/LinggangScheduling.java
| ... | ... | @@ -9,6 +9,7 @@ import lombok.AllArgsConstructor; |
| 9 | 9 | import lombok.Data; |
| 10 | 10 | import lombok.NoArgsConstructor; |
| 11 | 11 | import lombok.extern.slf4j.Slf4j; |
| 12 | +import org.apache.commons.lang3.StringUtils; | |
| 12 | 13 | |
| 13 | 14 | import java.util.Date; |
| 14 | 15 | |
| ... | ... | @@ -153,6 +154,10 @@ public class LinggangScheduling { |
| 153 | 154 | @TableField(exist = false) |
| 154 | 155 | private Date endScheduleDate; |
| 155 | 156 | |
| 157 | + public String getCheZhanCode(){ | |
| 158 | + return StringUtils.join(qdzcode,"@",zdzcode,"@",jobCode,"@"); | |
| 159 | + } | |
| 160 | + | |
| 156 | 161 | |
| 157 | 162 | |
| 158 | 163 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
| ... | ... | @@ -244,8 +244,9 @@ public class DriverJob implements InitializingBean { |
| 244 | 244 | @Transactional(rollbackFor = Exception.class) |
| 245 | 245 | public void getSchedulingInfo() { |
| 246 | 246 | Date date = new Date(); |
| 247 | - JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRandomValue()); | |
| 247 | + | |
| 248 | 248 | for (int i = 0; i < 2; i++) { |
| 249 | + JwtAuthenticationTokenFilter.putMDC("job",JwtAuthenticationTokenFilter.getRandomValue()); | |
| 249 | 250 | runScheduling(DateUtils.addDays(date, i).getTime()); |
| 250 | 251 | } |
| 251 | 252 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/key/location/LinggangKeyWorkLocationServiceImpl.java
| ... | ... | @@ -101,7 +101,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | private static void switchTime(LinggangKeyWorkLocation entity, LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper) { |
| 104 | - if(Objects.isNull(entity) || Objects.isNull(wrapper)){ | |
| 104 | + if (Objects.isNull(entity) || Objects.isNull(wrapper)) { | |
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | if (Objects.nonNull(entity.getStartScheduleDate()) && Objects.nonNull(entity.getEndScheduleDate())) { |
| ... | ... | @@ -114,7 +114,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | private static void switchTypes(LinggangKeyWorkLocation entity, LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper) { |
| 117 | - if(Objects.isNull(entity) || Objects.isNull(wrapper)){ | |
| 117 | + if (Objects.isNull(entity) || Objects.isNull(wrapper)) { | |
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
| ... | ... | @@ -208,18 +208,18 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 208 | 208 | keyInfoIds = null; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - List<Map<String,Date>> dateMaps = new ArrayList<>(); | |
| 211 | + List<Map<String, Date>> dateMaps = new ArrayList<>(); | |
| 212 | 212 | for (Date date : dates) { |
| 213 | 213 | Date endDate = DateUtils.addDays(date, 1); |
| 214 | 214 | |
| 215 | - Map<String,Date> maps = new HashMap<>(); | |
| 216 | - maps.put("startDate",date); | |
| 217 | - maps.put("endDate",endDate); | |
| 215 | + Map<String, Date> maps = new HashMap<>(); | |
| 216 | + maps.put("startDate", date); | |
| 217 | + maps.put("endDate", endDate); | |
| 218 | 218 | dateMaps.add(maps); |
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - return linggangKeyWorkLocationMapper.listRecentDates(keyInfoIds,dateMaps); | |
| 222 | + return linggangKeyWorkLocationMapper.listRecentDates(keyInfoIds, dateMaps); | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // @Override |
| ... | ... | @@ -292,6 +292,8 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | + log.info("分配钥匙所存放的柜子:[{}]", timeStr); | |
| 296 | + | |
| 295 | 297 | Date date = DateUtil.YYYY_MM_DD_LINK.parse(timeStr); |
| 296 | 298 | LinggangKeyWorkLocation workLocation = new LinggangKeyWorkLocation(); |
| 297 | 299 | workLocation.setStartScheduleDate(date); |
| ... | ... | @@ -339,10 +341,10 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 339 | 341 | List<LinggangKeyWorkLocation> error = new ArrayList<>(); |
| 340 | 342 | source.forEach(s -> { |
| 341 | 343 | boolean flag = false; |
| 342 | - if(Objects.isNull(s.getId())){ | |
| 344 | + if (Objects.isNull(s.getId())) { | |
| 343 | 345 | flag = save(s); |
| 344 | - }else{ | |
| 345 | - flag = update(s); | |
| 346 | + } else { | |
| 347 | + flag = update(s); | |
| 346 | 348 | } |
| 347 | 349 | |
| 348 | 350 | if (flag) { |
| ... | ... | @@ -372,7 +374,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 372 | 374 | public boolean update(LinggangKeyWorkLocation location) { |
| 373 | 375 | LambdaUpdateWrapper<LinggangKeyWorkLocation> wrapper = new LambdaUpdateWrapper<>(); |
| 374 | 376 | wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date()) |
| 375 | - .set(LinggangKeyWorkLocation::getType, location.getType()).set(LinggangKeyWorkLocation::getDevice,location.getDevice()); | |
| 377 | + .set(LinggangKeyWorkLocation::getType, location.getType()).set(LinggangKeyWorkLocation::getDevice, location.getDevice()); | |
| 376 | 378 | wrapper.eq(LinggangKeyWorkLocation::getId, location.getId()); |
| 377 | 379 | |
| 378 | 380 | return update(wrapper); |
| ... | ... | @@ -478,7 +480,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 478 | 480 | |
| 479 | 481 | List<LinggangKeyWorkLocation> sources = listRecentDates(dates, keyIds).stream().filter(s -> !Objects.equals(s.getType(), typeEnum.getValue())).collect(Collectors.toList()); |
| 480 | 482 | if (CollectionUtils.isEmpty(sources)) { |
| 481 | - log.info("[{}] 无法找到钥匙归还信息",locations); | |
| 483 | + log.info("[{}] 无法找到钥匙归还信息", locations); | |
| 482 | 484 | return ResponseResult.success(locations); |
| 483 | 485 | // return ResponseResult.error404("无法找到钥匙归还信息"); |
| 484 | 486 | } |
| ... | ... | @@ -504,7 +506,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 504 | 506 | Set<Long> schedulingIds = sources.stream().map(LinggangKeyWorkLocation::getSchedulingId).collect(Collectors.toSet()); |
| 505 | 507 | List<LinggangScheduling> schedulings = schedulingService.listByIds(schedulingIds); |
| 506 | 508 | if (CollectionUtils.isEmpty(schedulings)) { |
| 507 | - log.info("[{}] 无法找到钥匙归还信息",locations); | |
| 509 | + log.info("[{}] 无法找到钥匙归还信息", locations); | |
| 508 | 510 | return ResponseResult.success(locations); |
| 509 | 511 | // return ResponseResult.error404("无法找到排班信息"); |
| 510 | 512 | } |
| ... | ... | @@ -520,14 +522,14 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 520 | 522 | if (optional.isPresent()) { |
| 521 | 523 | l.setId(optional.get().getId()); |
| 522 | 524 | } |
| 523 | - Optional<LinggangScheduling> scheOpt = schedulings.stream().filter(s1->Objects.equals(s1.getId(),l.getSchedulingId())).findFirst(); | |
| 524 | - if(scheOpt.isPresent()){ | |
| 525 | - if(l.getTime().getTime()<scheOpt.get().getZdsjT()){ | |
| 525 | + Optional<LinggangScheduling> scheOpt = schedulings.stream().filter(s1 -> Objects.equals(s1.getId(), l.getSchedulingId())).findFirst(); | |
| 526 | + if (scheOpt.isPresent()) { | |
| 527 | + if (l.getTime().getTime() < scheOpt.get().getZdsjT()) { | |
| 526 | 528 | return null; |
| 527 | 529 | } |
| 528 | 530 | } |
| 529 | 531 | return l; |
| 530 | - }).filter(obj->Objects.nonNull(obj)).collect(Collectors.toList()); | |
| 532 | + }).filter(obj -> Objects.nonNull(obj)).collect(Collectors.toList()); | |
| 531 | 533 | |
| 532 | 534 | |
| 533 | 535 | return ResponseResult.success(locations); |
| ... | ... | @@ -807,6 +809,9 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 807 | 809 | log.info("没有查到排班信息:[{}]", date); |
| 808 | 810 | return null; |
| 809 | 811 | } |
| 812 | + | |
| 813 | + //schedulings =schedulings.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(s -> s.getCheZhanCode()))), ArrayList::new)); | |
| 814 | + | |
| 810 | 815 | return schedulings; |
| 811 | 816 | } |
| 812 | 817 | |
| ... | ... | @@ -901,7 +906,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 901 | 906 | private List<Equipment> queryEquipment(List<LinggangVenueInfo> venueInfos) { |
| 902 | 907 | Set<Integer> venuInfoIds = venueInfos.stream().map(LinggangVenueInfo::getId).collect(Collectors.toSet()); |
| 903 | 908 | Equipment equipment = new Equipment(); |
| 904 | - equipment.setStatus(1); | |
| 909 | +// equipment.setStatus(1); | |
| 905 | 910 | List<Equipment> equipmentList = equipmentService.listByEntityAndYardIds(equipment, venuInfoIds); |
| 906 | 911 | if (CollectionUtils.isEmpty(equipmentList)) { |
| 907 | 912 | log.info("查询设备数据为空:[{}]", venuInfoIds); | ... | ... |