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 209  
210 210 @PostMapping(value = "/Driver/SkipOperation")
211 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 213 if (bindingResult.hasErrors()) {
214 214 return ResponseResult.error(bindingResult.getFieldError().getDefaultMessage());
215 215 }
... ... @@ -225,11 +225,16 @@ public class KeyBoxController extends BaseController {
225 225  
226 226 @PostMapping(value = "Driver/TakeKey")
227 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 229 if (bindingResult.hasErrors()) {
230 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 238 ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.TAKE_OUT);
234 239 if (Objects.isNull(responseResult)) {
235 240 return ResponseResult.error();
... ... @@ -245,7 +250,11 @@ public class KeyBoxController extends BaseController {
245 250 if (bindingResult.hasErrors()) {
246 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 258 ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.REPAY);
250 259 if (Objects.isNull(responseResult)) {
251 260 return ResponseResult.error();
... ... @@ -545,7 +554,7 @@ public class KeyBoxController extends BaseController {
545 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 558 if (CollectionUtils.isEmpty(dto.getKeyItem())) {
550 559 return Collections.emptyList();
551 560 }
... ... @@ -553,12 +562,19 @@ public class KeyBoxController extends BaseController {
553 562 return dto.getKeyItem().stream().map(item -> {
554 563 LinggangKeyWorkLocation location = new LinggangKeyWorkLocation();
555 564 location.setDevice(item.getDevice());
556   - location.setEventType(item.getState());
  565 + location.setEventType(dto.getOpeType());
557 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 576 return location;
561   - }).collect(Collectors.toList());
  577 + }).filter(obj->Objects.nonNull(obj.getKeyInfoId())).collect(Collectors.toList());
562 578 }
563 579  
564 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 281  
282 282 public boolean update(LinggangKeyWorkLocation location) {
283 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 287 return update(wrapper);
288 288 }
... ... @@ -365,22 +365,13 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl&lt;LinggangKeyW
365 365 }
366 366  
367 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 370 if (CollectionUtils.isEmpty(keyInfos)) {
371 371 log.info("无法找到钥匙信息:[{}]", locations);
372 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 375 StringBuilder resultStr = new StringBuilder();
385 376 List<LinggangKeyWorkLocation> source = locations.stream().filter(l -> Objects.nonNull(l.getKeyInfoId())).collect(Collectors.toList());
386 377 List<LinggangKeyWorkLocation> target = locations.stream().filter(l -> Objects.isNull(l.getKeyInfoId())).collect(Collectors.toList());
... ...