| | |
| | | } |
| | | |
| | | @Override |
| | | public R getDeviceFreezeStatus() { |
| | | List<BasDevice> devices = basDeviceService.selectList(new EntityWrapper<BasDevice>() |
| | | .eq("status", 1) |
| | | .orderBy("dev_no", true)); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R releaseAllLocks() { |
| | | EntityWrapper<LocAroundBind> frozenWrapper = new EntityWrapper<>(); |
| | | frozenWrapper.eq("freeze", 1); |
| | | int frozenCount = locAroundBindService.selectCount(frozenWrapper); |
| | | if (frozenCount <= 0) { |
| | | return R.ok("全部机台工位均未冻结"); |
| | | } |
| | | |
| | | LocAroundBind updateEntity = new LocAroundBind(); |
| | | updateEntity.setFreeze(0); |
| | | EntityWrapper<LocAroundBind> updateWrapper = new EntityWrapper<>(); |
| | | updateWrapper.eq("freeze", 1); |
| | | if (!locAroundBindService.update(updateEntity, updateWrapper)) { |
| | | throw new CoolException("全部机台工位解冻失败,请检查后再操作!!"); |
| | | } |
| | | return R.ok("全部机台工位解冻成功,共处理" + frozenCount + "个工位"); |
| | | } |
| | | |
| | | @Override |
| | | public R getDeviceFreezeStatus(String devNo) { |
| | | EntityWrapper<BasDevice> deviceWrapper = new EntityWrapper<>(); |
| | | deviceWrapper.eq("status", 1); |
| | | deviceWrapper.orderBy("dev_no", true); |
| | | if (!Cools.isEmpty(devNo)) { |
| | | deviceWrapper.eq("dev_no", devNo.trim()); |
| | | } |
| | | List<BasDevice> devices = basDeviceService.selectList(deviceWrapper); |
| | | if (Cools.isEmpty(devices)) { |
| | | if (!Cools.isEmpty(devNo)) { |
| | | return R.error("机台[" + devNo + "]不存在或已禁用"); |
| | | } |
| | | return R.ok(Collections.emptyList()); |
| | | } |
| | | |
| | | List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>() |
| | | .orderBy("dev_no", true) |
| | | .orderBy("order_no", true) |
| | | .orderBy("id", true)); |
| | | Set<String> deviceTypes = devices.stream() |
| | | .map(BasDevice::getType) |
| | | .filter(type -> !Cools.isEmpty(type)) |
| | | .collect(Collectors.toCollection(LinkedHashSet::new)); |
| | | |
| | | EntityWrapper<LocAroundBind> bindWrapper = new EntityWrapper<>(); |
| | | bindWrapper.orderBy("dev_no", true); |
| | | bindWrapper.orderBy("order_no", true); |
| | | bindWrapper.orderBy("id", true); |
| | | if (!Cools.isEmpty(deviceTypes)) { |
| | | bindWrapper.in("dev_no", deviceTypes); |
| | | } |
| | | List<LocAroundBind> binds = locAroundBindService.selectList(bindWrapper); |
| | | Map<String, List<LocAroundBind>> bindMap = new HashMap<>(); |
| | | if (!Cools.isEmpty(binds)) { |
| | | bindMap = binds.stream() |