Commit c5cf607fa71586adf99d885e4a542530235ce9ee

Authored by liujun001
1 parent 0a29b019

钥匙归还

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