Commit 02e1576d91c20937907e79ac4c846dfea99b578f

Authored by liujun001
1 parent ec4fb43c

设备和场地

Bsth-admin/src/main/java/com/ruoyi/controller/dss/KeyBoxController.java
@@ -209,7 +209,7 @@ public class KeyBoxController extends BaseController { @@ -209,7 +209,7 @@ public class KeyBoxController extends BaseController {
209 209
210 @PostMapping(value = "/Driver/SkipOperation") 210 @PostMapping(value = "/Driver/SkipOperation")
211 @ApiOperation(value = "19.人员跳过钥匙柜操作") 211 @ApiOperation(value = "19.人员跳过钥匙柜操作")
212 - public ResponseResult<SkipOperationVo> skipOperation(@Valid SkipOperationDTO dto, BindingResult bindingResult) { 212 + public ResponseResult<SkipOperationVo> skipOperation(@Valid @RequestBody SkipOperationDTO dto, BindingResult bindingResult) {
213 if (bindingResult.hasErrors()) { 213 if (bindingResult.hasErrors()) {
214 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage()); 214 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage());
215 } 215 }
@@ -225,11 +225,16 @@ public class KeyBoxController extends BaseController { @@ -225,11 +225,16 @@ public class KeyBoxController extends BaseController {
225 225
226 @PostMapping(value = "Driver/TakeKey") 226 @PostMapping(value = "Driver/TakeKey")
227 @ApiOperation(value = "20.人员领取钥匙") 227 @ApiOperation(value = "20.人员领取钥匙")
228 - public ResponseResult<TakeKeyVo> takeKey(@Valid TakeKeyDTO dto, BindingResult bindingResult) { 228 + public ResponseResult<TakeKeyVo> takeKey(@Valid @RequestBody TakeKeyDTO dto, BindingResult bindingResult) {
229 if (bindingResult.hasErrors()) { 229 if (bindingResult.hasErrors()) {
230 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage()); 230 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage());
231 } 231 }
232 - List<LinggangKeyWorkLocation> locations = convert(dto); 232 +
  233 + LinggangKeyWorkLocation entity = new LinggangKeyWorkLocation();
  234 + entity.setDevice(dto.getDevice());
  235 + List<LinggangKeyWorkLocation> schedulings = linggangKeyWorkLocationService.list(entity);
  236 +
  237 + List<LinggangKeyWorkLocation> locations = convert(dto,schedulings);
233 ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.TAKE_OUT); 238 ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.TAKE_OUT);
234 if (Objects.isNull(responseResult)) { 239 if (Objects.isNull(responseResult)) {
235 return ResponseResult.error(); 240 return ResponseResult.error();
@@ -245,7 +250,11 @@ public class KeyBoxController extends BaseController { @@ -245,7 +250,11 @@ public class KeyBoxController extends BaseController {
245 if (bindingResult.hasErrors()) { 250 if (bindingResult.hasErrors()) {
246 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage()); 251 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage());
247 } 252 }
248 - List<LinggangKeyWorkLocation> locations = convert(dto); 253 + LinggangKeyWorkLocation entity = new LinggangKeyWorkLocation();
  254 + entity.setDevice(dto.getDevice());
  255 + List<LinggangKeyWorkLocation> schedulings = linggangKeyWorkLocationService.list(entity);
  256 +
  257 + List<LinggangKeyWorkLocation> locations = convert(dto,schedulings);
249 ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.REPAY); 258 ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.REPAY);
250 if (Objects.isNull(responseResult)) { 259 if (Objects.isNull(responseResult)) {
251 return ResponseResult.error(); 260 return ResponseResult.error();
@@ -545,7 +554,7 @@ public class KeyBoxController extends BaseController { @@ -545,7 +554,7 @@ public class KeyBoxController extends BaseController {
545 return vo; 554 return vo;
546 } 555 }
547 556
548 - private List<LinggangKeyWorkLocation> convert(TakeKeyDTO dto) { 557 + private List<LinggangKeyWorkLocation> convert(TakeKeyDTO dto,List<LinggangKeyWorkLocation> schedulings) {
549 if (CollectionUtils.isEmpty(dto.getKeyItem())) { 558 if (CollectionUtils.isEmpty(dto.getKeyItem())) {
550 return Collections.emptyList(); 559 return Collections.emptyList();
551 } 560 }
@@ -553,12 +562,19 @@ public class KeyBoxController extends BaseController { @@ -553,12 +562,19 @@ public class KeyBoxController extends BaseController {
553 return dto.getKeyItem().stream().map(item -> { 562 return dto.getKeyItem().stream().map(item -> {
554 LinggangKeyWorkLocation location = new LinggangKeyWorkLocation(); 563 LinggangKeyWorkLocation location = new LinggangKeyWorkLocation();
555 location.setDevice(item.getDevice()); 564 location.setDevice(item.getDevice());
556 - location.setEventType(item.getState()); 565 + location.setEventType(dto.getOpeType());
557 location.setKey(item.getKey()); 566 location.setKey(item.getKey());
558 - location.setScheduleDate(dto.getTime()); 567 + location.setScheduleDate(DateUtil.shortDate(dto.getTime()));
  568 + location.setType(item.getState());
  569 + if(CollectionUtils.isNotEmpty(schedulings)){
  570 + Optional<LinggangKeyWorkLocation> opt = schedulings.stream().filter(s->Objects.equals(item.getKey(),s.getCabinetNo())).findFirst();
  571 + if(opt.isPresent()){
  572 + location.setKeyInfoId(opt.get().getKeyInfoId());
  573 + }
  574 + }
559 575
560 return location; 576 return location;
561 - }).collect(Collectors.toList()); 577 + }).filter(obj->Objects.nonNull(obj.getKeyInfoId())).collect(Collectors.toList());
562 } 578 }
563 579
564 private TakeKeyVo convertTakeKeyVo(TakeKeyDTO dto, ResponseResult<Boolean> result) { 580 private TakeKeyVo convertTakeKeyVo(TakeKeyDTO dto, ResponseResult<Boolean> result) {
Bsth-admin/src/main/java/com/ruoyi/service/impl/key/location/LinggangKeyWorkLocationServiceImpl.java
@@ -281,8 +281,8 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl&lt;LinggangKeyW @@ -281,8 +281,8 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl&lt;LinggangKeyW
281 281
282 public boolean update(LinggangKeyWorkLocation location) { 282 public boolean update(LinggangKeyWorkLocation location) {
283 LambdaUpdateWrapper<LinggangKeyWorkLocation> wrapper = new LambdaUpdateWrapper<>(); 283 LambdaUpdateWrapper<LinggangKeyWorkLocation> wrapper = new LambdaUpdateWrapper<>();
284 - wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date());  
285 - wrapper.eq(LinggangKeyWorkLocation::getId, location.getId()).ne(LinggangKeyWorkLocation::getEventType, location.getEventType()); 284 + wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date()).set(LinggangKeyWorkLocation::getType,location.getType());
  285 + wrapper.eq(LinggangKeyWorkLocation::getId, location.getId()).ne(LinggangKeyWorkLocation::getType, location.getType());
286 286
287 return update(wrapper); 287 return update(wrapper);
288 } 288 }
@@ -365,22 +365,13 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl&lt;LinggangKeyW @@ -365,22 +365,13 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl&lt;LinggangKeyW
365 } 365 }
366 366
367 private ResponseResult<List<LinggangKeyWorkLocation>> checkTaskKey(List<LinggangKeyWorkLocation> locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum typeEnum) { 367 private ResponseResult<List<LinggangKeyWorkLocation>> checkTaskKey(List<LinggangKeyWorkLocation> locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum typeEnum) {
368 - Set<String> keyCodes = locations.stream().map(LinggangKeyWorkLocation::getKey).collect(Collectors.toSet());  
369 - List<KeyInfo> keyInfos = keyInfoService.list(keyCodes); 368 + Set<Integer> keyCodes = locations.stream().map(LinggangKeyWorkLocation::getKeyInfoId).collect(Collectors.toSet());
  369 + List<KeyInfo> keyInfos = keyInfoService.listByIds(keyCodes);
370 if (CollectionUtils.isEmpty(keyInfos)) { 370 if (CollectionUtils.isEmpty(keyInfos)) {
371 log.info("无法找到钥匙信息:[{}]", locations); 371 log.info("无法找到钥匙信息:[{}]", locations);
372 return ResponseResult.error404("无法找到钥匙信息"); 372 return ResponseResult.error404("无法找到钥匙信息");
373 } 373 }
374 374
375 - locations = locations.stream().map(lo -> {  
376 - Optional<KeyInfo> optional = keyInfos.stream().filter(k -> Objects.equals(k.getKeyCode(), lo.getKey())).findFirst();  
377 - if (optional.isPresent()) {  
378 - lo.setKeyInfoId(optional.get().getId());  
379 - }  
380 -  
381 - return lo;  
382 - }).collect(Collectors.toList());  
383 -  
384 StringBuilder resultStr = new StringBuilder(); 375 StringBuilder resultStr = new StringBuilder();
385 List<LinggangKeyWorkLocation> source = locations.stream().filter(l -> Objects.nonNull(l.getKeyInfoId())).collect(Collectors.toList()); 376 List<LinggangKeyWorkLocation> source = locations.stream().filter(l -> Objects.nonNull(l.getKeyInfoId())).collect(Collectors.toList());
386 List<LinggangKeyWorkLocation> target = locations.stream().filter(l -> Objects.isNull(l.getKeyInfoId())).collect(Collectors.toList()); 377 List<LinggangKeyWorkLocation> target = locations.stream().filter(l -> Objects.isNull(l.getKeyInfoId())).collect(Collectors.toList());