Commit bdc1a9f19e7fbc3104dc40b2fc055f3bddad17b4
1 parent
c469c2f0
设备和场地
Showing
4 changed files
with
78 additions
and
7 deletions
Bsth-admin/src/main/java/com/ruoyi/controller/dss/KeyBoxController.java
| ... | ... | @@ -234,7 +234,9 @@ public class KeyBoxController extends BaseController { |
| 234 | 234 | entity.setDevice(dto.getDevice()); |
| 235 | 235 | List<LinggangKeyWorkLocation> schedulings = linggangKeyWorkLocationService.list(entity); |
| 236 | 236 | |
| 237 | - List<LinggangKeyWorkLocation> locations = convert(dto, schedulings); | |
| 237 | + NewDriver driver = newDriverService.getOne(dto.getDriverCode()); | |
| 238 | + | |
| 239 | + List<LinggangKeyWorkLocation> locations = convert(dto, schedulings,driver); | |
| 238 | 240 | ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.TAKE_OUT); |
| 239 | 241 | if (Objects.isNull(responseResult)) { |
| 240 | 242 | return ResponseResult.error(); |
| ... | ... | @@ -254,7 +256,9 @@ public class KeyBoxController extends BaseController { |
| 254 | 256 | entity.setDevice(dto.getDevice()); |
| 255 | 257 | List<LinggangKeyWorkLocation> schedulings = linggangKeyWorkLocationService.list(entity); |
| 256 | 258 | |
| 257 | - List<LinggangKeyWorkLocation> locations = convert(dto, schedulings); | |
| 259 | + NewDriver driver = newDriverService.getOne(dto.getDriverCode()); | |
| 260 | + | |
| 261 | + List<LinggangKeyWorkLocation> locations = convert(dto, schedulings,driver); | |
| 258 | 262 | ResponseResult<Boolean> responseResult = linggangKeyWorkLocationService.updateTakeKey(locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum.REPAY); |
| 259 | 263 | if (Objects.isNull(responseResult)) { |
| 260 | 264 | return ResponseResult.error(); |
| ... | ... | @@ -554,7 +558,7 @@ public class KeyBoxController extends BaseController { |
| 554 | 558 | return vo; |
| 555 | 559 | } |
| 556 | 560 | |
| 557 | - private List<LinggangKeyWorkLocation> convert(TakeKeyDTO dto, List<LinggangKeyWorkLocation> schedulings) { | |
| 561 | + private List<LinggangKeyWorkLocation> convert(TakeKeyDTO dto, List<LinggangKeyWorkLocation> schedulings,NewDriver driver) { | |
| 558 | 562 | if (CollectionUtils.isEmpty(dto.getKeyItem())) { |
| 559 | 563 | return Collections.emptyList(); |
| 560 | 564 | } |
| ... | ... | @@ -573,6 +577,9 @@ public class KeyBoxController extends BaseController { |
| 573 | 577 | } |
| 574 | 578 | } |
| 575 | 579 | |
| 580 | + location.setCreateBy(Convert.toLong(driver.getId())); | |
| 581 | + location.setCreateTime(new Date()); | |
| 582 | + | |
| 576 | 583 | return location; |
| 577 | 584 | }).filter(obj -> Objects.nonNull(obj.getKeyInfoId())).collect(Collectors.toList()); |
| 578 | 585 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/driver/NewDriverService.java
Bsth-admin/src/main/java/com/ruoyi/service/impl/driver/NewDriverServiceImpl.java
| ... | ... | @@ -139,6 +139,13 @@ public class NewDriverServiceImpl extends ServiceImpl<NewDriverMapper, NewDriver |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | @Override |
| 142 | + public NewDriver getOne(String jobCode) { | |
| 143 | + LambdaQueryWrapper<NewDriver> wrapper = new LambdaQueryWrapper<>(); | |
| 144 | + wrapper.eq(NewDriver::getJobCode,jobCode); | |
| 145 | + return getOne(wrapper); | |
| 146 | + } | |
| 147 | + | |
| 148 | + @Override | |
| 142 | 149 | public Integer countId(NewDriver entity) { |
| 143 | 150 | LambdaQueryWrapper<NewDriver> wrapper = new LambdaQueryWrapper<>(entity); |
| 144 | 151 | wrapper.select(NewDriver::getJobCode); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/key/location/LinggangKeyWorkLocationServiceImpl.java
| 1 | 1 | package com.ruoyi.service.impl.key.location; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.convert.Convert; | |
| 3 | 4 | import com.alibaba.fastjson2.JSON; |
| 5 | +import com.alibaba.fastjson2.JSONArray; | |
| 6 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 7 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 5 | 8 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 6 | 9 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| ... | ... | @@ -11,6 +14,7 @@ import com.ruoyi.common.TipEnum; |
| 11 | 14 | import com.ruoyi.common.core.domain.ResponseResult; |
| 12 | 15 | import com.ruoyi.domain.OrderEntity; |
| 13 | 16 | import com.ruoyi.domain.caiinfo.CarInfo; |
| 17 | +import com.ruoyi.domain.equipment.heartbeat.LingangEquipmentHeartbeat; | |
| 14 | 18 | import com.ruoyi.domain.key.info.KeyInfo; |
| 15 | 19 | import com.ruoyi.domain.key.location.LinggangKeyWorkLocation; |
| 16 | 20 | import com.ruoyi.domain.scheduling.LinggangScheduling; |
| ... | ... | @@ -19,6 +23,7 @@ import com.ruoyi.equipment.domain.Equipment; |
| 19 | 23 | import com.ruoyi.equipment.service.IEquipmentService; |
| 20 | 24 | import com.ruoyi.mapper.key.location.LinggangKeyWorkLocationMapper; |
| 21 | 25 | import com.ruoyi.service.carinfo.CarInfoService; |
| 26 | +import com.ruoyi.service.equipment.heartbeat.LingangEquipmentHeartbeatService; | |
| 22 | 27 | import com.ruoyi.service.key.info.KeyInfoService; |
| 23 | 28 | import com.ruoyi.service.key.location.LinggangKeyWorkLocationService; |
| 24 | 29 | import com.ruoyi.service.scheduling.LinggangSchedulingService; |
| ... | ... | @@ -57,6 +62,8 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 57 | 62 | private IEquipmentService equipmentService; |
| 58 | 63 | @Autowired |
| 59 | 64 | private CarInfoService carInfoService; |
| 65 | + @Autowired | |
| 66 | + private LingangEquipmentHeartbeatService equipmentHeartbeatService; | |
| 60 | 67 | |
| 61 | 68 | private static final String TAKE_KEY_MSG = "设备号:{0},钥匙编号:{1},在{2}的状态已经是:{3},无需在操作"; |
| 62 | 69 | private static final String TAKE_KEY_SUCESS = "设备号:{0},钥匙编号:{1},在{2}的状已经更新成功"; |
| ... | ... | @@ -104,7 +111,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 104 | 111 | @Override |
| 105 | 112 | public List<LinggangKeyWorkLocation> list(LinggangKeyWorkLocation entity) { |
| 106 | 113 | LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = new LambdaQueryWrapper<>(entity); |
| 107 | - switchTime(entity,wrapper); | |
| 114 | + switchTime(entity, wrapper); | |
| 108 | 115 | return list(wrapper); |
| 109 | 116 | } |
| 110 | 117 | |
| ... | ... | @@ -187,7 +194,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 187 | 194 | public Integer countId(LinggangKeyWorkLocation entity) { |
| 188 | 195 | LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = new LambdaQueryWrapper<>(entity); |
| 189 | 196 | wrapper.select(LinggangKeyWorkLocation::getId); |
| 190 | - switchTime(entity,wrapper); | |
| 197 | + switchTime(entity, wrapper); | |
| 191 | 198 | return count(wrapper); |
| 192 | 199 | } |
| 193 | 200 | |
| ... | ... | @@ -284,7 +291,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 284 | 291 | |
| 285 | 292 | public boolean update(LinggangKeyWorkLocation location) { |
| 286 | 293 | LambdaUpdateWrapper<LinggangKeyWorkLocation> wrapper = new LambdaUpdateWrapper<>(); |
| 287 | - wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date()).set(LinggangKeyWorkLocation::getType,location.getType()); | |
| 294 | + wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date()).set(LinggangKeyWorkLocation::getType, location.getType()); | |
| 288 | 295 | wrapper.eq(LinggangKeyWorkLocation::getId, location.getId()).ne(LinggangKeyWorkLocation::getType, location.getType()); |
| 289 | 296 | |
| 290 | 297 | return update(wrapper); |
| ... | ... | @@ -586,7 +593,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 586 | 593 | continue; |
| 587 | 594 | } |
| 588 | 595 | if (Objects.isNull(equipment.getLatticeNumberSet())) { |
| 589 | - equipment.setLatticeNumberSet(new HashSet<>(equipment.getLatticeNumber())); | |
| 596 | + equipment.setLatticeNumberSet(combationLattice(equipment)); | |
| 590 | 597 | } |
| 591 | 598 | |
| 592 | 599 | number = RandomUtils.nextInt(1, equipment.getLatticeNumber()); |
| ... | ... | @@ -644,6 +651,54 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 644 | 651 | return schedulings; |
| 645 | 652 | } |
| 646 | 653 | |
| 654 | + private Set<Integer> combationLattice(Equipment equipment) { | |
| 655 | + if (Objects.isNull(equipment)) { | |
| 656 | + return null; | |
| 657 | + } | |
| 658 | + if (CollectionUtils.isNotEmpty(equipment.getLatticeNumberSet())) { | |
| 659 | + return equipment.getLatticeNumberSet(); | |
| 660 | + } | |
| 661 | + | |
| 662 | + Set<Integer> latticeNumber = new HashSet<>(); | |
| 663 | + | |
| 664 | + LingangEquipmentHeartbeat heartbeat = new LingangEquipmentHeartbeat(); | |
| 665 | + heartbeat.setDevice(equipment.getDeviceId()); | |
| 666 | + IPage<LingangEquipmentHeartbeat> heartbeatIPage = equipmentHeartbeatService.pageList(new Page<>(1, 1), heartbeat, new OrderEntity()); | |
| 667 | + if (Objects.nonNull(heartbeatIPage) && CollectionUtils.isNotEmpty(heartbeatIPage.getRecords())) { | |
| 668 | + heartbeatIPage.getRecords().stream().forEach(hb -> { | |
| 669 | + if (StringUtils.isNotEmpty(hb.getExkeys())) { | |
| 670 | + JSONArray jsonArray = JSONArray.parseArray(hb.getExkeys()); | |
| 671 | + if (CollectionUtils.isNotEmpty(jsonArray)) { | |
| 672 | + jsonArray.stream().forEach(object -> { | |
| 673 | + if (object instanceof JSONObject) { | |
| 674 | + JSONObject jo = (JSONObject) object; | |
| 675 | + Object value = jo.get("key"); | |
| 676 | + if (Objects.nonNull(value)) { | |
| 677 | + latticeNumber.add(Convert.toInt(value)); | |
| 678 | + } | |
| 679 | + } | |
| 680 | + }); | |
| 681 | + } | |
| 682 | + | |
| 683 | + } | |
| 684 | + }); | |
| 685 | + } | |
| 686 | + | |
| 687 | + LinggangKeyWorkLocation location = new LinggangKeyWorkLocation(); | |
| 688 | + location.setDevice(equipment.getDeviceId()); | |
| 689 | + location.setType(2); | |
| 690 | + | |
| 691 | + | |
| 692 | + List<LinggangKeyWorkLocation> locations = list(location); | |
| 693 | + if (CollectionUtils.isNotEmpty(locations)) { | |
| 694 | + locations.stream().forEach(l -> { | |
| 695 | + latticeNumber.add(Convert.toInt(l.getCabinetNo())); | |
| 696 | + }); | |
| 697 | + } | |
| 698 | + | |
| 699 | + return latticeNumber; | |
| 700 | + } | |
| 701 | + | |
| 647 | 702 | private List<LinggangVenueInfo> queryVenueInfo(List<LinggangScheduling> schedulings) { |
| 648 | 703 | Set<String> zdzCode = schedulings.stream().map(LinggangScheduling::getZdzcode).collect(Collectors.toSet()); |
| 649 | 704 | List<LinggangVenueInfo> venueInfos = venueInfoService.listOfCodes(zdzCode); | ... | ... |