package com.bonus.core.device.manage.service;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.core.device.manage.dto.DeviceSearchDTO;
import com.bonus.core.device.manage.mapper.DeviceInfoMapper;
import com.bonus.core.device.manage.model.DeviceInfo;
import com.bonus.core.device.manage.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class DeviceInfoService {
   private static final Logger log = LoggerFactory.getLogger(DeviceInfoService.class);
   private static final Long CACHE_EXPIRE_SECOND = 3600L;
   @Autowired
   private DeviceInfoMapper deviceInfoMapper;
//   @Autowired
//   private DeviceInfoInSystemMapper deviceInfoInSystemMapper;
   @Autowired
   private DeviceBindService deviceBindService;
//   @Autowired
//   private DeviceBindMapper deviceBindMapper;
   @Autowired
   @Lazy
   private DeviceLockerCabinetService deviceLockerCabinetService;
//   @Autowired
//   private DeviceLockerService deviceLockerService;
   @Autowired
   private DeviceRecipeService deviceRecipeService;
   @Autowired
   private DeviceDishesService deviceDishesService;
   @Autowired
   private DeviceControlRelationService deviceControlRelationService;
//   @Autowired
//   private AllocCanteenApi allocCanteenApi;
//   @Autowired
//   private MenuDishesApi menuDishesApi;
//   @Autowired
//   private DeviceDcTerminalService deviceDcTerminalService;
//   @Autowired
//   private DeviceDcDoorService deviceDcDoorService;
//   @Autowired
//   private RedisTemplate<Object, Object> redis;
//   @Autowired
//   @Lazy
//   private ShouqianbaPayUtil shouqianbaPayUtil;
//   @Autowired
//   @Lazy
//   private FeiePrint feiePrint;
   @Autowired
   private DeviceMetadataService deviceMetadataService;
//   @Autowired
//   private DevicePrintExtSettingApi devicePrintExtSettingApi;
//   @Autowired
//   private BusDeviceInfoService busDeviceInfoService;
//   @Autowired
//   private MenuRecipeApi menuRecipeApi;
//
//   @Transactional(
//      rollbackFor = {Exception.class}
//   )
//   public void insert(DeviceDTO dto) {
//      this.validateDevicePostParam(dto, false);
//      dto.setDeviceId(Id.next());
//      DeviceInfo deviceInfoEntity = dto.convertToInfoEntity();
//      this.deviceInfoMapper.insert(deviceInfoEntity);
//      this.deviceBindService.insert(dto.getBinds());
//      List<DeviceRecipeDTO> dtoList = this.menuRecipeApi.getBindByTypeAndStalls(dto.getBinds(), deviceInfoEntity.getDeviceType());
//      this.deviceRecipeService.insert(BeanUtil.copyToList(dto.getBinds(), DeviceRecipeDTO.class).stream().map((deviceRecipeDTO) -> {
//         dtoList.forEach((s) -> {
//            if (ObjectUtil.equals(deviceRecipeDTO.getCanteenId(), s.getCanteenId()) && ObjectUtil.equals(deviceRecipeDTO.getStallId(), s.getStallId())) {
//               deviceRecipeDTO.setRecipeId(s.getRecipeId());
//            }
//
//         });
//         return deviceRecipeDTO;
//      }).toList());
//      this.deviceDishesService.insert(dto.getDishes());
//      this.deviceControlRelationService.insert(dto.getControlRelations());
//      if (ObjectUtil.isNotEmpty(dto.getMetadata())) {
//         this.deviceMetadataService.saveDeviceMetadata(this.saveMetadataModelHandle(dto.getDeviceId(), getDeviceMap(dto.getDeviceType(), dto.getMetadata())));
//      }
//
//      if (DeviceStrategy.isFeiePrinter(deviceInfoEntity.getDeviceType(), deviceInfoEntity.getDeviceModel())) {
//         FeiePrintResponse printAddRes = this.feiePrint.addprinter(deviceInfoEntity.getDeviceSn(), deviceInfoEntity.getPriKey(), deviceInfoEntity.getDeviceName());
//         if (null == printAddRes) {
//            throw new LeException("添加打印机出现异常信息,返回参数为空");
//         }
//
//         if (!printAddRes.isSuccess()) {
//            throw new LeException(printAddRes.getMsg());
//         }
//
//         this.devicePrintExtSettingApi.setPrinterSize(dto);
//      }
//
//      if (DeviceStrategy.isLocker(deviceInfoEntity.getDeviceType())) {
//         List<DeviceLockerCabinetDTO> cabinetDtoList = dto.getCabinets();
//         int totalLockerCount = cabinetDtoList.stream().mapToInt(DeviceLockerCabinetDTO::getLockerCount).sum();
//         if (totalLockerCount <= 0) {
//            throw new LeException("参数错误,取餐柜格子总数小于等于0");
//         }
//
//         cabinetDtoList.forEach((s) -> {
//            s.setCabinetId(Id.next());
//         });
//         this.deviceLockerCabinetService.insert(cabinetDtoList);
//         this.deviceLockerService.insertByCount(deviceInfoEntity.getDeviceId(), totalLockerCount);
//      }
//
//      if (DeviceStrategy.isDoorTerminal(deviceInfoEntity.getDeviceType())) {
//         DeviceDcTerminal deviceDcTerminal = (DeviceDcTerminal)BeanUtil.copyProperties(dto, DeviceDcTerminal.class, new String[0]);
//         this.deviceDcTerminalService.insert(deviceDcTerminal);
//         this.deviceDcDoorService.updateByIndexAndDevice(dto.getDeviceId(), dto.getDoors());
//      }
//
//      if (DeviceStrategy.isDoor(deviceInfoEntity.getDeviceType())) {
//         DeviceDcDoor deviceDcDoor = (DeviceDcDoor)BeanUtil.copyProperties(dto, DeviceDcDoor.class, new String[0]);
//         this.deviceDcDoorService.insert(deviceDcDoor);
//      }
//
//      if (DeviceStrategy.isBusDevice(deviceInfoEntity.getDeviceType())) {
//         BusDeviceInfo busDeviceInfo = (BusDeviceInfo)BeanUtil.copyProperties(dto, BusDeviceInfo.class, new String[0]);
//         this.busDeviceInfoService.save(busDeviceInfo);
//      }
//
//      this.cleanDeviceCache(dto.getDeviceParentId());
//      DeviceInfoInSystem deviceInfoEntityInSys = deviceInfoEntity.convertToSystem();
//      this.insertDeviceInSys(deviceInfoEntityInSys);
//   }
//
//   @Transactional(
//      rollbackFor = {Exception.class}
//   )
//   public void update(DeviceDTO dto) {
//      this.validateDevicePostParam(dto, true);
//      DeviceInfo deviceInfo = this.getDeviceInfoBySnCacheable(dto.getDeviceSn());
//      if (ObjectUtil.isNotEmpty(deviceInfo)) {
//         this.cleanDeviceCache(deviceInfo.getDeviceParentId());
//      }
//
//      DeviceInfo deviceInfoEntity = dto.convertToInfoEntity();
//      this.deviceInfoMapper.updateById(deviceInfoEntity);
//      this.deviceBindService.update(deviceInfoEntity.getDeviceId(), dto.getBinds());
//      List<DeviceRecipeDTO> dtoList = this.menuRecipeApi.getBindByTypeAndStalls(dto.getBinds(), deviceInfoEntity.getDeviceType());
//      this.deviceRecipeService.update(deviceInfoEntity.getDeviceId(), BeanUtil.copyToList(dto.getBinds(), DeviceRecipeDTO.class).stream().map((deviceRecipeDTO) -> {
//         dtoList.forEach((s) -> {
//            if (ObjectUtil.equals(deviceRecipeDTO.getCanteenId(), s.getCanteenId()) && ObjectUtil.equals(deviceRecipeDTO.getStallId(), s.getStallId())) {
//               deviceRecipeDTO.setRecipeId(s.getRecipeId());
//            }
//
//         });
//         return deviceRecipeDTO;
//      }).toList());
//      this.deviceDishesService.update(deviceInfoEntity.getDeviceId(), dto.getDishes());
//      this.deviceControlRelationService.update(deviceInfoEntity.getDeviceId(), dto.getControlRelations());
//      if (ObjectUtil.isNotEmpty(dto.getMetadata())) {
//         this.deviceMetadataService.saveDeviceMetadata(this.saveMetadataModelHandle(dto.getDeviceId(), getDeviceMap(dto.getDeviceType(), dto.getMetadata())));
//      }
//
//      if (DeviceStrategy.isLocker(dto.getDeviceType())) {
//         List<DeviceLockerCabinetDTO> cabinetDtoList = dto.getCabinets();
//         boolean changeLockerCabinet = this.isChangeLockerCabinet(dto, cabinetDtoList);
//         int totalLockerCount = cabinetDtoList.stream().mapToInt(DeviceLockerCabinetDTO::getLockerCount).sum();
//         if (changeLockerCabinet) {
//            this.deviceLockerService.updateByDeviceId(deviceInfoEntity.getDeviceId(), totalLockerCount);
//            this.deviceLockerCabinetService.update(deviceInfoEntity.getDeviceId(), cabinetDtoList);
//         }
//      }
//
//      if (DeviceStrategy.isDoorTerminal(dto.getDeviceType())) {
//         DeviceDcTerminal deviceDcTerminal = (DeviceDcTerminal)BeanUtil.copyProperties(dto, DeviceDcTerminal.class, new String[0]);
//         this.deviceDcTerminalService.update(deviceDcTerminal);
//         this.deviceDcDoorService.updateByIndexAndDevice(dto.getDeviceId(), dto.getDoors());
//      }
//
//      if (DeviceStrategy.isFeiePrinter(deviceInfoEntity.getDeviceType(), deviceInfoEntity.getDeviceModel())) {
//         this.devicePrintExtSettingApi.setPrinterSize(dto);
//      }
//
//      if (DeviceStrategy.isBusDevice(dto.getDeviceType())) {
//         BusDeviceInfo busDeviceInfo = (BusDeviceInfo)BeanUtil.copyProperties(dto, BusDeviceInfo.class, new String[0]);
//         this.busDeviceInfoService.update(busDeviceInfo, (Wrapper)Wrappers.lambdaUpdate(BusDeviceInfo.class).eq(BusDeviceInfo::getDeviceId, busDeviceInfo.getDeviceId()));
//      }
//
//      this.cleanDeviceCache(deviceInfoEntity.getDeviceSn());
//      this.cleanDeviceCache(deviceInfoEntity.getDeviceParentId());
//      DeviceInfoInSystem deviceInfoEntityInSys = deviceInfoEntity.convertToSystem();
//      this.updateDeviceInSys(deviceInfoEntityInSys);
//      if (ObjectUtil.isNotEmpty(dto.getMetadata())) {
//         MacMessage.updateDeviceMetadataV2Setting(dto.getMetadata(), dto.getDeviceSn());
//      }
//
//      DeviceFullInfoVO deviceFullInfoVO = this.getDeviceFullInfoVoBySnCacheable(dto.getDeviceSn());
//      DeviceMqMessage.deviceUpdateInfoV4(DeviceInfoVO.of(deviceFullInfoVO), dto.getDeviceSn());
//   }
//
//   private boolean isChangeLockerCabinet(DeviceDTO dto, List<DeviceLockerCabinetDTO> cabinetDtoList) {
//      CheckLockerCabinetChangeDto source = new CheckLockerCabinetChangeDto();
//      source.setLockerCabinetDTOList(cabinetDtoList);
//      List<DeviceLockerCabinet> dbLockerCabinetList = this.deviceLockerCabinetService.listByDeviceIds(Lists.newArrayList(new Long[]{dto.getDeviceId()}));
//      List<DeviceLockerCabinetDTO> lockerCabinetDTOList = BeanUtil.copyToList(dbLockerCabinetList, DeviceLockerCabinetDTO.class);
//      CheckLockerCabinetChangeDto dbDto = new CheckLockerCabinetChangeDto();
//      dbDto.setLockerCabinetDTOList(lockerCabinetDTOList);
//      return !source.equals(dbDto);
//   }
//
//   public void insertDeviceInSys(DeviceInfoInSystem deviceInfoEntityInSys) {
//      Executors.doInSystem((s) -> {
//         this.deviceInfoInSystemMapper.insert(deviceInfoEntityInSys);
//      });
//   }
//
//   public void updateDeviceInSys(DeviceInfoInSystem deviceInfoEntityInSys) {
//      Executors.doInSystem((s) -> {
//         this.deviceInfoInSystemMapper.updateById(deviceInfoEntityInSys);
//      });
//   }
//
//   public void deleteDeviceInSys(long deviceId) {
//      Executors.doInSystem((s) -> {
//         this.deviceInfoInSystemMapper.deleteById(deviceId);
//      });
//   }
//
//   public void updateTerminalKeyByDeviceSn(String deviceSn, String terminalKey) {
//      this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, deviceSn)).set(DeviceInfo::getTerminalKey, terminalKey));
//      this.cleanDeviceCache(deviceSn);
//   }
//
//   public void updatePwdBySn(String deviceSn, String devicePwd) {
//      this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, deviceSn)).set(DeviceInfo::getDevicePwd, devicePwd));
//      this.cleanDeviceCache(deviceSn);
//   }
//
//   public void updateDataStatusBySn(String deviceSn, Integer dataStatus) {
//      this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, deviceSn)).set(DeviceInfo::getDataStatus, dataStatus));
//      this.cleanDeviceCache(deviceSn);
//   }
//
//   public void editMacRecipe(MenuRecipeMachineChangeDTO dto) {
//      List<DeviceRecipeDTO> bindInsertDtoList = (List)dto.getMachineIdList().stream().map((s) -> {
//         DeviceRecipeDTO bind = new DeviceRecipeDTO();
//         bind.setDeviceId(s);
//         bind.setCanteenId(dto.getCanteenId());
//         bind.setStallId(dto.getShopstallId());
//         bind.setRecipeId(dto.getRecipeId());
//         bind.setMealLineId(dto.getMealLineId());
//         return bind;
//      }).collect(Collectors.toList());
//      this.deviceRecipeService.update(bindInsertDtoList);
//      this.cleanDeviceCacheByIds(dto.getMachineIdList());
//   }
//
//   public void editMacRecipeBydevice(MenuRecipeMachineChangeDTO dto) {
//      this.deviceRecipeService.updateRecipeByCanteenOrStall(dto.getCanteenId(), dto.getShopstallId(), dto.getRecipeId(), dto.getMachineIdList());
//      log.info("更新设备菜谱成功");
//      this.cleanDeviceCacheByIds(dto.getMachineIdList());
//   }
//
//   public void deleteMacRecipeBydevice(MenuRecipeMachineChangeDTO dto) {
//      this.deviceRecipeService.updateRecipeByCanteenOrStall(dto.getCanteenId(), dto.getShopstallId(), (Long)null, dto.getMachineIdList());
//      this.cleanDeviceCacheByIds(dto.getMachineIdList());
//   }
//
//   public void updateRecipeByCanteenOrStall(Long canteenId, Long stallId, Long recipeId) {
//      if (canteenId == null && stallId == null) {
//         throw new LeException("档口id和食堂id不能都为空");
//      } else {
//         List<DeviceInfo> deviceInfoList = this.list((new DeviceSearchDTO()).setCanteenId(canteenId).setStallId(stallId));
//         this.deviceRecipeService.updateRecipeByDeviceIdList(deviceInfoList.stream().map(DeviceInfo::getDeviceId).toList(), recipeId);
//         if (CollUtil.isNotEmpty(deviceInfoList)) {
//            this.cleanDeviceCacheBySnList(deviceInfoList.stream().map(DeviceInfo::getDeviceSn).toList());
//         }
//
//      }
//   }
//
//   public void updateDeviceDishes(DeviceDishesUpdateDTO dto) {
//      this.deviceDishesService.update(dto.getDeviceId(), dto.convertToDeviceDishes());
//      this.cleanDeviceCache(dto.getDeviceId());
//      List<MenuLabelAndNutritionVO> dishesList = CollUtil.isNotEmpty(dto.getDishesIds()) ? this.menuDishesApi.getDishesLabelAndNutritionList(dto.getDishesIds()) : ListUtil.empty();
//      DeviceInfo deviceInfo = this.getById(dto.getDeviceId());
//      MacMessage.sendToClient(dishesList, LeMqConstant.Topic.DEVICE_UPDATE_BIND_DISHES, deviceInfo.getDeviceSn());
//   }
//
//   public void updateMetadataAndroid(DeviceAndroidDTO deviceAndroidDTO) {
//      DeviceInfo deviceInfo = this.getBySn(deviceAndroidDTO.getDeviceSn());
//      if (ObjectUtil.isEmpty(deviceInfo)) {
//         throw new LeException("设备不存在");
//      } else {
//         if (ObjectUtil.isNotEmpty(deviceAndroidDTO.getMetadata())) {
//            this.deviceMetadataService.saveDeviceMetadata(this.saveMetadataModelHandle(deviceInfo.getDeviceId(), getDeviceMap(deviceAndroidDTO.getDeviceType(), deviceAndroidDTO.getMetadata())));
//         }
//
//         this.cleanDeviceCache(deviceAndroidDTO.getDeviceSn());
//      }
//   }
//
//   public void updateAllInOneMetadata(DeviceAndroidDTO deviceAndroidDTO) {
//      DeviceInfo deviceInfo = this.getBySn(deviceAndroidDTO.getAllInOneSn());
//      if (ObjectUtil.isEmpty(deviceInfo)) {
//         throw new LeException("设备不存在");
//      } else {
//         if (ObjectUtil.isNotEmpty(deviceAndroidDTO.getMetadata())) {
//            this.deviceMetadataService.saveDeviceMetadata(this.saveMetadataModelHandle(deviceInfo.getDeviceId(), getDeviceMap(deviceAndroidDTO.getDeviceType(), deviceAndroidDTO.getMetadata())));
//         }
//
//      }
//   }
//
//   public void updateMachineMqttOnlineState(String deviceSn, Integer state, Integer versionCode, String versionName) {
//      this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, deviceSn)).set(DeviceInfo::getOnlineState, state)).set(DeviceInfo::getVersionCode, versionCode)).set(DeviceInfo::getVersionName, versionName));
//      this.cleanDeviceCache(deviceSn);
//   }
//
//   public void updateDeviceState(String deviceSn, Integer state) {
//      this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, deviceSn)).set(DeviceInfo::getDeviceState, state));
//      this.cleanDeviceCache(deviceSn);
//   }
//
//   public void changeOnlineStateByDeviceIds(List<Long> deviceIds, int onlineState) {
//      if (!CollUtil.isEmpty(deviceIds)) {
//         this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).set(DeviceInfo::getOnlineState, onlineState)).in(DeviceInfo::getDeviceId, deviceIds));
//         this.cleanDeviceCacheByIds(deviceIds);
//      }
//   }
//
//   @Transactional(
//      rollbackFor = {Exception.class}
//   )
//   public void delete(Long deviceId) {
//      if (null == deviceId) {
//         throw new LeException("类型、id参数不足");
//      } else {
//         DeviceInfo deviceInfo = this.getById(deviceId);
//         if (deviceInfo == null) {
//            throw new LeException("设备不存在");
//         } else {
//            if (DeviceStrategy.isLocker(deviceInfo.getDeviceType())) {
//               this.deviceLockerService.deleteByDeviceId(deviceId);
//               this.deviceLockerCabinetService.deleteByDeviceId(deviceId);
//            }
//
//            if (DeviceStrategy.isFeiePrinter(deviceInfo.getDeviceType(), deviceInfo.getDeviceModel())) {
//               FeiePrintResponse printResponse = this.feiePrint.delPrinter(deviceInfo.getDeviceSn());
//               if (printResponse.isFailed()) {
//                  throw new LeException("删除打印机失败");
//               }
//            }
//
//            if (DeviceStrategy.isDoorTerminal(deviceInfo.getDeviceType())) {
//               this.deviceDcTerminalService.deleteByDeviceId(deviceId);
//            }
//
//            if (DeviceStrategy.isDoor(deviceInfo.getDeviceType())) {
//               this.deviceDcDoorService.deleteByDeviceId(deviceId);
//            }
//
//            if (DeviceStrategy.isBusDevice(deviceInfo.getDeviceType())) {
//               this.busDeviceInfoService.update((Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(BusDeviceInfo.class).set(BusDeviceInfo::getDelFlag, LeConstants.COMMON_YES)).eq(BusDeviceInfo::getDeviceId, deviceId));
//            }
//
//            this.deviceInfoMapper.deleteById(deviceId);
//            this.deviceBindService.deleteByDeviceId(deviceId);
//            this.deviceRecipeService.deleteByDeviceId(deviceId);
//            this.deviceDishesService.deleteByDeviceId(deviceId);
//            this.deviceControlRelationService.deleteByDeviceId(deviceId);
//            this.deviceMetadataService.deleteByDevice(deviceId);
//            this.menuRecipeApi.deleteByDevice(deviceInfo.getDeviceType());
//            this.cleanDeviceCache(deviceInfo.getDeviceSn());
//            this.cleanDeviceCache(deviceInfo.getDeviceParentId());
//            this.deleteDeviceInSys(deviceId);
//         }
//      }
//   }
//
//   public void updateIssueConfig(List<DeviceIssueDTO> dtoList) {
//      if (!CollUtil.isEmpty(dtoList)) {
//         Iterator var2 = dtoList.iterator();
//
//         while(var2.hasNext()) {
//            DeviceIssueDTO issueDTO = (DeviceIssueDTO)var2.next();
//            this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceId, issueDTO.getDeviceId())).set(DeviceInfo::getFontSize, issueDTO.getFontSize())).set(DeviceInfo::getFontColor, issueDTO.getFontColor())).set(DeviceInfo::getLineNum, issueDTO.getLineNum()));
//            this.cleanDeviceCache(issueDTO.getDeviceId());
//         }
//
//      }
//   }
//
//   public DeviceInfo getDeviceInfoBySnCacheable(String deviceSn) {
//      if (StrUtil.isEmpty(deviceSn)) {
//         return null;
//      } else {
//         String deviceRedisKey = MachineConstant.getDeviceSingleRedisKey(deviceSn);
//         LogUtil.printArgs("设备InfoV缓存key", deviceRedisKey);
//         Object obj = RedisUtil.getObj(deviceRedisKey);
//         if (obj instanceof DeviceInfo) {
//            return (DeviceInfo)obj;
//         } else {
//            DeviceInfo deviceInfo = this.getBySn(deviceSn);
//            if (deviceInfo != null) {
//               RedisUtil.setObj(deviceRedisKey, deviceInfo, CACHE_EXPIRE_SECOND);
//            }
//
//            return deviceInfo;
//         }
//      }
//   }
//
//   public net.xnzn.core.device.manage.vo.DeviceInfoVO getDeviceInfoVoBySnCacheable(String deviceSn) {
//      if (StrUtil.isEmpty(deviceSn)) {
//         return null;
//      } else {
//         String deviceRedisKey = MachineConstant.getDeviceRedisKey(deviceSn);
//         LogUtil.printArgs("设备InfoV缓存key", deviceRedisKey);
//         Object obj = RedisUtil.getObj(deviceRedisKey);
//         if (obj instanceof net.xnzn.core.device.manage.vo.DeviceInfoVO) {
//            return (net.xnzn.core.device.manage.vo.DeviceInfoVO)obj;
//         } else {
//            net.xnzn.core.device.manage.vo.DeviceInfoVO vo = this.getDeviceInfoVoBySn(deviceSn);
//            if (vo != null) {
//               RedisUtil.setObj(deviceRedisKey, vo, CACHE_EXPIRE_SECOND);
//            }
//
//            return vo;
//         }
//      }
//   }
//
//   public DeviceFullInfoVO getDeviceFullInfoVoBySnCacheable(String deviceSn) {
//      if (StrUtil.isEmpty(deviceSn)) {
//         return null;
//      } else {
//         String deviceFullRedisKey = MachineConstant.getDeviceFullRedisKey(deviceSn);
//         LogUtil.printArgs("设备FullInfoV缓存key", deviceFullRedisKey);
//         Object obj = RedisUtil.getObj(deviceFullRedisKey);
//         if (obj instanceof DeviceFullInfoVO) {
//            return (DeviceFullInfoVO)obj;
//         } else {
//            DeviceFullInfoVO vo = this.getDeviceFullInfoVoBySn(deviceSn);
//            if (vo != null) {
//               RedisUtil.setObj(deviceFullRedisKey, vo, CACHE_EXPIRE_SECOND);
//            }
//
//            return vo;
//         }
//      }
//   }
//
//   public List<DeviceFullInfoVO> getDeviceFullInfoVoBySnListCacheable(List<String> deviceSnList) {
//      return (List)(CollUtil.isEmpty(deviceSnList) ? CollUtil.newArrayList(new DeviceFullInfoVO[0]) : (List)deviceSnList.stream().map(this::getDeviceFullInfoVoBySnCacheable).filter(Objects::nonNull).collect(Collectors.toList()));
//   }
//
//   public net.xnzn.core.device.manage.vo.DeviceInfoVO getDeviceInfoVoBySn(String deviceSn) {
//      DeviceInfo deviceInfo = this.getBySn(deviceSn);
//      if (deviceInfo == null) {
//         return null;
//      } else {
//         List<net.xnzn.core.device.manage.vo.DeviceInfoVO> deviceInfoVOList = this.fillVo(CollUtil.toList(new DeviceInfo[]{deviceInfo}));
//         return (net.xnzn.core.device.manage.vo.DeviceInfoVO)deviceInfoVOList.get(0);
//      }
//   }
//
//   public net.xnzn.core.device.manage.vo.DeviceInfoVO getDeviceInfoVoByNum(String deviceNum) {
//      DeviceInfo deviceInfo = this.getByNum(deviceNum);
//      if (deviceInfo == null) {
//         return null;
//      } else {
//         List<net.xnzn.core.device.manage.vo.DeviceInfoVO> deviceInfoVOList = this.fillVo(CollUtil.toList(new DeviceInfo[]{deviceInfo}));
//         return (net.xnzn.core.device.manage.vo.DeviceInfoVO)deviceInfoVOList.get(0);
//      }
//   }
//
//   public List<net.xnzn.core.device.manage.vo.DeviceInfoVO> getDeviceInfoVoByNumList(List<String> deviceNumList) {
//      List<DeviceInfo> deviceInfoList = this.getByNumList(deviceNumList);
//      if (ObjectUtil.isEmpty(deviceInfoList)) {
//         return null;
//      } else {
//         List<net.xnzn.core.device.manage.vo.DeviceInfoVO> deviceInfoVOList = this.fillVo(deviceInfoList);
//         return deviceInfoVOList;
//      }
//   }
//
//   public net.xnzn.core.device.manage.vo.DeviceInfoVO getDeviceInfoVoById(Long deviceId) {
//      DeviceInfo deviceInfo = this.getById(deviceId);
//      if (deviceInfo == null) {
//         return null;
//      } else {
//         List<net.xnzn.core.device.manage.vo.DeviceInfoVO> deviceInfoVOList = this.fillVo(CollUtil.toList(new DeviceInfo[]{deviceInfo}));
//         return (net.xnzn.core.device.manage.vo.DeviceInfoVO)deviceInfoVOList.get(0);
//      }
//   }
//
//   public DeviceFullInfoVO getDeviceFullInfoVoBySn(String deviceSn) {
//      DeviceInfo deviceInfo = this.getBySn(deviceSn);
//      if (deviceInfo == null) {
//         return null;
//      } else {
//         List<DeviceFullInfoVO> deviceInfoVOList = this.fillFullVo(CollUtil.toList(new DeviceInfo[]{deviceInfo}));
//         return (DeviceFullInfoVO)deviceInfoVOList.get(0);
//      }
//   }
//
//   public DeviceInfo getById(Long deviceId) {
//      return (DeviceInfo)this.deviceInfoMapper.selectById(deviceId);
//   }

   public DeviceInfo getBySn(String deviceSn) {
      return (DeviceInfo)this.deviceInfoMapper.selectOne((Wrapper) Wrappers.lambdaQuery(DeviceInfo.class)
              .eq(DeviceInfo::getDeviceSn, deviceSn));
   }
//
//   public DeviceInfoInSystem getBySnInSys(String deviceSn) {
//      return (DeviceInfoInSystem)Executors.readInSystem(() -> {
//         return (DeviceInfoInSystem)this.deviceInfoInSystemMapper.selectOne((Wrapper)Wrappers.lambdaQuery(DeviceInfoInSystem.class).eq(DeviceInfoInSystem::getDeviceSn, deviceSn));
//      });
//   }
//
//   public DeviceInfo getByNum(String deviceNum) {
//      return (DeviceInfo)this.deviceInfoMapper.selectOne((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getDeviceNum, deviceNum));
//   }
//
//   public List<DeviceInfo> getByNumList(List<String> deviceNumList) {
//      return this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).in(DeviceInfo::getDeviceNum, deviceNumList));
//   }

   public Integer getMaxOrdNum(Long deviceId, Integer deviceType) {
      return this.deviceInfoMapper.getMaxOrdNum(deviceId, deviceType);
   }
//
//   public List<DeviceOrdNumVo> getMaxOrdNumList(List<Long> machineIdList, Integer mchType) {
//      return this.deviceInfoMapper.getMaxOrdNumList(machineIdList, mchType);
//   }
//
//   public List<DeviceInfo> listPaymentDevice() {
//      List<Integer> paymentTypes = DeviceStrategy.paymentDeviceTypes();
//      return this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).in(DeviceInfo::getDeviceType, paymentTypes));
//   }
//
//   public List<net.xnzn.core.device.manage.vo.DeviceInfoVO> listDeviceInfoVoByType(Integer type) {
//      List<DeviceInfo> deviceInfoList = this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getDeviceType, type));
//      return this.fillVo(deviceInfoList);
//   }
//
//   public List<net.xnzn.core.device.manage.vo.DeviceInfoVO> listDeviceInfoVoByParentId(DeviceInfo deviceInfo) {
//      String deviceChildRedisKey = MachineConstant.getDeviceChildRedisKey(deviceInfo.getDeviceSn());
//      LogUtil.printArgs("设备子设备缓存key", deviceChildRedisKey);
//      Object obj = RedisUtil.getObj(deviceChildRedisKey);
//      if (obj instanceof List) {
//         return (List)obj;
//      } else {
//         List<DeviceInfo> deviceInfoList = this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getDeviceParentId, deviceInfo.getDeviceId()));
//         List<net.xnzn.core.device.manage.vo.DeviceInfoVO> deviceInfoVOList = this.fillVo(deviceInfoList);
//         RedisUtil.setObj(deviceChildRedisKey, deviceInfoVOList, CACHE_EXPIRE_SECOND);
//         return deviceInfoVOList;
//      }
//   }

   public List<DeviceInfo> list(DeviceSearchDTO param) {
      return this.deviceInfoMapper.list(param != null ? param : new DeviceSearchDTO());
   }

//   public List<DeviceInfo> listPermission(DeviceSearchDTO param) {
//      param = param != null ? param : new DeviceSearchDTO();
//      return ObjectUtil.isNotEmpty(param.getDeviceTypeList()) && param.getDeviceTypeList().contains(SourceTypeEnum.PRODUCTION.getKey()) ? this.deviceInfoMapper.listpermissionchupinji(param) : this.deviceInfoMapper.listpermission(param);
//   }

   public List<DeviceInfo> listByIds(List<Long> deviceIds) {
      return (CollUtil.isEmpty(deviceIds) ? CollUtil.newArrayList(new DeviceInfo[0]) :
              this.deviceInfoMapper.selectList(Wrappers.lambdaQuery(DeviceInfo.class)
                      .in(DeviceInfo::getDeviceId, deviceIds)));
   }
//
//   public List<DeviceInfo> listByNames(Collection<String> deviceNameList) {
//      return CollUtil.isEmpty(deviceNameList) ? Collections.emptyList() : this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).in(DeviceInfo::getDeviceName, deviceNameList));
//   }
//
//   public List<String> getDiscountDeviceNameByDeviceIds(List<Long> deviceIds) {
//      if (CollUtil.isEmpty(deviceIds)) {
//         return Collections.emptyList();
//      } else {
//         List<DeviceInfo> deviceInfoList = this.deviceInfoMapper.selectList((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DeviceInfo.class).in(DeviceInfo::getDeviceId, deviceIds)).eq(DeviceInfo::getIfDiscount, LeConstants.COMMON_YES));
//         return (List)deviceInfoList.stream().map(DeviceInfo::getDeviceName).collect(Collectors.toList());
//      }
//   }
//
//   public List<net.xnzn.core.device.manage.vo.DeviceInfoVO> fillVo(List<DeviceInfo> deviceInfoList) {
//      if (CollUtil.isEmpty(deviceInfoList)) {
//         return ListUtil.empty();
//      } else {
//         List<Long> deviceIds = (List)deviceInfoList.stream().map(DeviceInfo::getDeviceId).collect(Collectors.toList());
//         Map<Long, List<DeviceBind>> deviceBindGroupByDeviceId = (Map)this.deviceBindService.listByDeviceIds(deviceIds).stream().collect(Collectors.groupingBy(DeviceBind::getDeviceId));
//         Map<Long, List<DeviceRecipe>> deviceRecipeGroupByDeviceId = (Map)this.deviceRecipeService.listByDeviceIds(deviceIds).stream().collect(Collectors.groupingBy(DeviceRecipe::getDeviceId));
//         Map<Long, List<DeviceDishes>> deviceDishesGroupByDeviceId = (Map)this.deviceDishesService.listByDeviceIds(deviceIds).stream().collect(Collectors.groupingBy(DeviceDishes::getDeviceId));
//         Map<Long, Map> deviceMetadataByDeviceId = this.deviceMetadataService.listDeviceMetadataBYDeviceIdList(deviceIds);
//         return (List)deviceInfoList.stream().map((s) -> {
//            net.xnzn.core.device.manage.vo.DeviceInfoVO vo = net.xnzn.core.device.manage.vo.DeviceInfoVO.of(s, (List)deviceBindGroupByDeviceId.get(s.getDeviceId()), (List)deviceRecipeGroupByDeviceId.get(s.getDeviceId()), (List)deviceDishesGroupByDeviceId.get(s.getDeviceId()), (Map)deviceMetadataByDeviceId.get(s.getDeviceId()));
//            vo.setHeartbeatStateCache(RedisUtil.getString(MachineConstant.getDeviceStateRedisKey(s.getDeviceSn())));
//            return vo;
//         }).collect(Collectors.toList());
//      }
//   }

   public List<DeviceFullInfoVO> fillFullVo(List<DeviceInfo> deviceInfoList) {
      if (CollUtil.isEmpty(deviceInfoList)) {
         return CollUtil.toList(new DeviceFullInfoVO[0]);
      } else {
         List<Long> deviceIds = deviceInfoList.stream().map(DeviceInfo::getDeviceId).collect(Collectors.toList());
         Map<Long, List<DeviceBindVO>> deviceBindGroupByDeviceId = this.deviceBindService.listVoByDeviceIds(deviceIds).stream().collect(Collectors.groupingBy(DeviceBindVO::getDeviceId));
         Map<Long, List<DeviceRecipeVO>> deviceRecipeGroupByDeviceId = this.deviceRecipeService.listVoByDeviceIds(deviceIds)
                 .stream().collect(Collectors.groupingBy(DeviceRecipeVO::getDeviceId));
         Map<Long, List<DeviceDishesVO>> deviceDishesGroupByDeviceId = this.deviceDishesService.listVoByDeviceIds(deviceIds)
                 .stream().collect(Collectors.groupingBy(DeviceDishesVO::getDeviceId));
         Map<Long, List<DeviceLockerCabinetVO>> cabinetListGroupByDeviceId = this.deviceLockerCabinetService
                 .listVoByDeviceIds(deviceIds).stream().collect(Collectors.groupingBy(DeviceLockerCabinetVO::getDeviceId));
         Map<Long, List<DeviceControlRelationVO>> relationGroupByDeviceId = this.deviceControlRelationService
                 .listVoByDeviceIds(deviceIds).stream().collect(Collectors.groupingBy(DeviceControlRelationVO::getControlDeviceId));
         Map<Long, Map> deviceMetadataByDeviceId = this.deviceMetadataService.listDeviceMetadataBYDeviceIdList(deviceIds);
         return deviceInfoList.stream().map((s) -> {
            DeviceFullInfoVO vo = DeviceFullInfoVO.of(s, deviceBindGroupByDeviceId.get(s.getDeviceId()),
                    deviceRecipeGroupByDeviceId.get(s.getDeviceId()), deviceDishesGroupByDeviceId.get(s.getDeviceId()),
                    cabinetListGroupByDeviceId.get(s.getDeviceId()), relationGroupByDeviceId.get(s.getDeviceId()),
                    deviceMetadataByDeviceId.get(s.getDeviceId()));
            return vo;
         }).collect(Collectors.toList());
      }
   }
//
//   public void cleanDeviceCache(String deviceSn) {
//      String deviceRedisKey = MachineConstant.getDeviceRedisKey(deviceSn);
//      String deviceFullRedisKey = MachineConstant.getDeviceFullRedisKey(deviceSn);
//      String deviceSingleRedisKey = MachineConstant.getDeviceSingleRedisKey(deviceSn);
//      String deviceChildRedisKey = MachineConstant.getDeviceChildRedisKey(deviceSn);
//      LogUtil.printArgs("清除缓存", deviceRedisKey, deviceFullRedisKey);
//      RedisUtil.delete(deviceRedisKey);
//      RedisUtil.delete(deviceFullRedisKey);
//      RedisUtil.delete(deviceSingleRedisKey);
//      RedisUtil.delete(deviceChildRedisKey);
//   }
//
//   public void cleanDeviceCache(Long deviceId) {
//      if (!Objects.isNull(deviceId)) {
//         DeviceInfo deviceInfo = this.getById(deviceId);
//         if (deviceInfo != null) {
//            this.cleanDeviceCache(deviceInfo.getDeviceSn());
//         }
//
//      }
//   }
//
//   public void cleanDeviceCacheBySnList(List<String> deviceSnList) {
//      if (!CollUtil.isEmpty(deviceSnList)) {
//         deviceSnList.forEach(this::cleanDeviceCache);
//      }
//   }
//
//   public void cleanDeviceCacheByIds(List<Long> deviceIds) {
//      if (!CollUtil.isEmpty(deviceIds)) {
//         List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
//         if (!CollUtil.isEmpty(deviceInfos)) {
//            this.cleanDeviceCacheBySnList(deviceInfos.stream().map(DeviceInfo::getDeviceSn).toList());
//            List<Long> parentIdList = ListUtil.toList(deviceInfos.stream().map(DeviceInfo::getDeviceParentId).distinct().toList());
//            if (!CollUtil.isEmpty(deviceInfos)) {
//               List<DeviceInfo> deviceInfoParents = this.listByIds(parentIdList);
//               this.cleanDeviceCacheBySnList(deviceInfoParents.stream().map(DeviceInfo::getDeviceSn).toList());
//            }
//         }
//      }
//   }
//
//   public Long getLocalTimeStamp(String machineSn) {
//      if (StrUtil.isNotEmpty(machineSn) && ObjectUtil.isNotEmpty(TenantContextHolder.getTenantId())) {
//         String machineStateRedisKey = MachineConstant.getDeviceStateRedisKey(machineSn);
//         if (!RedisUtil.setIfPresentString(machineStateRedisKey, machineSn, 60L)) {
//            this.updateMachineMqttOnlineState(machineSn, 1, (Integer)null, (String)null);
//            RedisUtil.setString(machineStateRedisKey, machineSn, 60L);
//         }
//
//         MqUtil.sendDelay(JacksonUtil.writeValueAsString(DeviceHeartDTO.buildHeartbeatInfo(machineSn, TenantContextHolder.getTenantId())), LeMqConstant.Topic.DEVICE_HEARTBEAT, 70000);
//      }
//
//      return Instant.now().toEpochMilli();
//   }
//
//   public SqbBizResponse shouqianbaActivate(SqbActivationDTO content) {
//      SqbBizResult sqbBizResult = this.shouqianbaPayUtil.active(content.getCode(), content.getMachineSn());
//      if (StrUtil.isNotBlank(sqbBizResult.getTerminal_sn()) && StrUtil.isNotBlank(sqbBizResult.getTerminal_key())) {
//         SqbBizResponse sqbBizResponse = new SqbBizResponse();
//         sqbBizResponse.setTerminalKey(sqbBizResult.getTerminal_key());
//         sqbBizResponse.setTerminalSn(sqbBizResult.getTerminal_sn());
//         this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceSn, content.getMachineSn())).set(DeviceInfo::getTerminalSn, sqbBizResponse.getTerminalSn())).set(DeviceInfo::getTerminalKey, sqbBizResponse.getTerminalKey()));
//         return sqbBizResponse;
//      } else {
//         return null;
//      }
//   }
//
//   private void validateDevicePostParam(DeviceDTO params, boolean isUpdate) {
//      Integer deviceType = params.getDeviceType();
//      if (deviceType == null) {
//         throw new LeException("设备类型不能为空");
//      } else if (!DeviceStrategy.supportsMultiBind(deviceType) && CollUtil.size(params.getBinds()) > 1) {
//         throw new LeException("不支持多个食堂/档口绑定");
//      } else {
//         Iterator var4 = params.getBinds().iterator();
//
//         while(var4.hasNext()) {
//            DeviceBindDTO bindDto = (DeviceBindDTO)var4.next();
//            if (null != bindDto.getCanteenId()) {
//               AllocCanteen basicsDining = this.allocCanteenApi.getAllocCanteen(bindDto.getCanteenId());
//               if (basicsDining == null) {
//                  throw new LeException(RetCodeEnum.CORE_PARAM_ERROR, "食堂不存在");
//               }
//            }
//         }
//
//         DeviceInfoInSystem deviceBySnInSys = this.getBySnInSys(params.getDeviceSn());
//         if ((isUpdate || deviceBySnInSys == null) && (!isUpdate || deviceBySnInSys == null || ObjectUtil.equal(deviceBySnInSys.getDeviceId(), params.getDeviceId()))) {
//            DeviceInfo deviceByNum = this.getByNum(params.getDeviceNum());
//            if (!isUpdate && deviceByNum != null || isUpdate && deviceByNum != null && !ObjectUtil.equal(deviceByNum.getDeviceId(), params.getDeviceId())) {
//               throw new LeException("[设备管理]设备编号已存在");
//            } else if (DeviceStrategy.isPrinter(deviceType) && StrUtil.isEmpty(params.getDeviceModel())) {
//               throw new LeException("打印机设备型号不能为空");
//            } else if (DeviceStrategy.isLocker(deviceType) && CollUtil.isEmpty(params.getCabinets())) {
//               throw new LeException("[设备管理]取餐柜编号、柜门数量为空");
//            }
//         } else {
//            log.error("[设备管理]设备已存在" + params.getDeviceSn());
//            throw new LeException("[设备管理]设备已存在sn===>" + params.getDeviceSn() + "已存在");
//         }
//      }
//   }
//
//   public boolean checkCanteenStallRelation(Long canteenId, Long stallId, Long mealLineId) {
//      long count = this.deviceBindMapper.selectCount(((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DeviceBind.class).eq(ObjectUtil.isNotNull(canteenId), DeviceBind::getCanteenId, canteenId)).eq(ObjectUtil.isNotNull(stallId), DeviceBind::getStallId, stallId)).eq(ObjectUtil.isNotNull(mealLineId), DeviceBind::getMealLineId, mealLineId));
//      return count > 0L;
//   }
//
//   public List<MacTcpStateVo> queryDeviceLayoutRecipe(DeviceSearchDTO param) {
//      List<DeviceInfo> deviceInfos = this.list(param);
//      if (CollUtil.isEmpty(deviceInfos)) {
//         return CollUtil.newArrayList(new MacTcpStateVo[0]);
//      } else {
//         List<DeviceFullInfoVO> deviceFullInfoVOList = this.fillFullVo(deviceInfos);
//         List<MacTcpStateVo> macTcpStateVoList = new ArrayList();
//         deviceFullInfoVOList.stream().forEach((machineCounterVO) -> {
//            MacTcpStateVo macTcpStateVo = new MacTcpStateVo();
//            macTcpStateVo.setRecipeId(machineCounterVO.getFirstRecipeId());
//            Object object = this.redis.opsForValue().get("yunshitang:merchantId:isonline:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//            macTcpStateVo.setMchNum(machineCounterVO.getDeviceNum());
//            macTcpStateVo.setIfOnline(2);
//            macTcpStateVo.setMchType(machineCounterVO.getDeviceType());
//            macTcpStateVo.setMchModel(machineCounterVO.getDeviceModel());
//            if (object != null) {
//               macTcpStateVo.setIfOnline(1);
//            }
//
//            Object lastsendtime;
//            Object menustate;
//            if ("2".equals(machineCounterVO.getDeviceModel())) {
//               lastsendtime = this.redis.opsForValue().get("yunshitang:merchantId:recipesendtime:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//               if (lastsendtime != null) {
//                  macTcpStateVo.setLastSendTime(((String)lastsendtime).replaceAll("\"", ""));
//               }
//
//               menustate = this.redis.opsForValue().get("yunshitang:merchantId:menustate:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//               if (menustate != null) {
//                  macTcpStateVo.setMenuState((Integer)menustate);
//               }
//            } else {
//               lastsendtime = this.redis.opsForValue().get("yunshitang:merchantId:recipesendtime:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//               if (lastsendtime != null) {
//                  macTcpStateVo.setLastSendTime(((String)lastsendtime).replaceAll("\"", ""));
//               }
//
//               menustate = this.redis.opsForValue().get("yunshitang:merchantId:menustate:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//               if (menustate != null) {
//                  macTcpStateVo.setMenuState((Integer)menustate);
//               }
//            }
//
//            menustate = this.redis.opsForValue().get("yunshitang:merchantId:menustate:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//            if (menustate != null) {
//               macTcpStateVo.setMenuState((Integer)menustate);
//            }
//
//            Object macip = this.redis.opsForValue().get("yunshitang:merchantId:macip:macNumber".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("macNumber", machineCounterVO.getDeviceNum()));
//            if (menustate != null) {
//               macTcpStateVo.setMchIp((String)macip);
//            }
//
//            Object o = this.redis.opsForValue().get(String.format("yunshitang:%s:heartbase:%s", TenantContextHolder.getTenantId().toString(), machineCounterVO.getDeviceNum()));
//            if (!Objects.isNull(o)) {
//               MacHeartBeatVo macHeartBeatVo = (MacHeartBeatVo)JSON.parseObject(String.valueOf(o), MacHeartBeatVo.class);
//               macTcpStateVo.setMenuName(macHeartBeatVo.getMenuName());
//               if (macHeartBeatVo.getMenuUpTime() != null) {
//                  macTcpStateVo.setMenuUpTime(LocalDateTimeUtil.format(macHeartBeatVo.getMenuUpTime(), "yyyy-MM-dd HH:mm:ss"));
//               }
//
//               macTcpStateVo.setMenuNo(macHeartBeatVo.getMenuNo());
//               macTcpStateVo.setMenuName(macHeartBeatVo.getMenuName());
//            }
//
//            if (macTcpStateVo.getMenuNo() != null && macTcpStateVo.getMenuNo() != 0) {
//               MenuDishes dish = this.menuDishesApi.getOneMenuDishesByCustomId(macTcpStateVo.getMenuNo());
//               if (dish != null) {
//                  macTcpStateVo.setPrice(dish.getPrice());
//                  macTcpStateVo.setUnitPrice(dish.getUnitPrice());
//                  macTcpStateVo.setSalesMode(dish.getSalesMode());
//               }
//            }
//
//            if (StrUtil.isEmpty(macTcpStateVo.getMenuName())) {
//               macTcpStateVo.setMenuName("");
//            }
//
//            if (macTcpStateVo.getMenuWeight() == null) {
//               macTcpStateVo.setMenuWeight(0);
//            }
//
//            if (macTcpStateVo.getMenuPrice() == null) {
//               macTcpStateVo.setMenuPrice(0);
//            }
//
//            if (macTcpStateVo.getPrice() == null) {
//               macTcpStateVo.setPrice(0);
//            }
//
//            if (macTcpStateVo.getUnitPrice() == null) {
//               macTcpStateVo.setUnitPrice(0);
//            }
//
//            macTcpStateVoList.add(macTcpStateVo);
//         });
//         return macTcpStateVoList;
//      }
//   }
//
//   public List<DeviceInfo> getAllCabinets() {
//      return this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getDeviceType, SourceTypeEnum.MEAL_LOCKER.getKey()));
//   }
//
//   public List<DeviceInfo> getOnlineByDeviceType(Integer type) {
//      return this.deviceInfoMapper.selectList((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getOnlineState, LeConstants.COMMON_YES)).eq(DeviceInfo::getDeviceType, type));
//   }
//
//   public List<DeviceInfo> getByDeviceType(Integer type) {
//      return this.deviceInfoMapper.selectList((Wrapper)Wrappers.lambdaQuery(DeviceInfo.class).eq(DeviceInfo::getDeviceType, type));
//   }
//
//   public void updateByEntity(DeviceInfo deviceInfo) {
//      this.deviceInfoMapper.update(deviceInfo, (Wrapper)Wrappers.lambdaUpdate(DeviceInfo.class).eq(DeviceInfo::getDeviceId, deviceInfo.getDeviceId()));
//   }
//
//   public void changeOnlineState(String sn, int onlineState) {
//      this.deviceInfoMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DeviceInfo.class).set(DeviceInfo::getOnlineState, onlineState)).eq(DeviceInfo::getDeviceSn, sn));
//   }
//
//   public static Map getDeviceMap(Integer deviceType, Map<String, Object> metadata) {
//      List<String> fieldStream = (List)Arrays.stream(ReflectUtil.getFields(DeviceMtadataFactory.createMetadata(deviceType).getClass())).map(Field::getName).collect(Collectors.toList());
//      Map mapmetadata = (Map)metadata.entrySet().stream().filter((map) -> {
//         return fieldStream.contains(map.getKey());
//      }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
//      return mapmetadata;
//   }
//
//   public List<DeviceMetadata> saveMetadataModelHandle(Long deviceId, Map<String, Object> mapmetadata) {
//      List<DeviceMetadata> deviceMetadataList = new ArrayList();
//      Iterator var4 = mapmetadata.keySet().iterator();
//
//      while(var4.hasNext()) {
//         String key = (String)var4.next();
//         Object o = mapmetadata.get(key);
//         if (o instanceof ArrayList) {
//            if (ObjectUtil.equal(key, "imageMap")) {
//               List<String> a = (ArrayList)mapmetadata.get(key);
//               o = a.stream().map((s) -> {
//                  return SysUtil.getCutPath(s);
//               }).collect(Collectors.toList());
//            }
//
//            deviceMetadataList.add(new DeviceMetadata(deviceId, key, JSONObject.toJSON(o).toString()));
//         } else {
//            deviceMetadataList.add(new DeviceMetadata(deviceId, key, mapmetadata.get(key).toString()));
//         }
//      }
//
//      return deviceMetadataList;
//   }
//
//   public List<MarketDeviceTreeVO> listTenantDevice(List<Integer> deviceTypes, List<Long> canteenIds, List<Long> stallIds) {
//      return this.deviceInfoMapper.listTenantDevice(deviceTypes, canteenIds, stallIds);
//   }
//
//   public AllInOneDto getGateWayInfoByDeviceSn(String deviceSn) {
//      AllInOneDto allInOneDto = new AllInOneDto();
//      DeviceInfo deviceInfo = this.getBySn(deviceSn);
//      if (ObjectUtil.isNull(deviceInfo)) {
//         throw new LeException("未获取到设备信息");
//      } else {
//         String deviceParentType = deviceInfo.getDeviceParentType();
//         if (!String.valueOf(SourceTypeEnum.WEIGHT_PRODUCTION_IN_ONE.getKey()).equals(deviceParentType)) {
//            throw new LeException("未绑定称重出品一体机");
//         } else {
//            Long oneAllInDeviceId = deviceInfo.getDeviceParentId();
//            DeviceInfo oneAllInDevice = this.getById(oneAllInDeviceId);
//            allInOneDto.setAllInOneSn(oneAllInDevice.getDeviceSn());
//            if (ObjectUtil.isNull(oneAllInDevice)) {
//               throw new LeException("未获取到计量主机绑定的称重出品一体机信息");
//            } else {
//               String oneAllInDeviceParentType = oneAllInDevice.getDeviceParentType();
//               if (!String.valueOf(SourceTypeEnum.WEIGHT_PRODUCTION_IN_ONE_CONTROLS.getKey()).equals(oneAllInDeviceParentType)) {
//                  throw new LeException("称重出品一体机未绑定称重出品一体机控制终端");
//               } else {
//                  Long oneAllInDeviceParentId = oneAllInDevice.getDeviceParentId();
//                  DeviceInfo gateWayDevice = this.getById(oneAllInDeviceParentId);
//                  if (ObjectUtil.isNull(gateWayDevice)) {
//                     throw new LeException("未获取到称重出品一体机控制终端信息");
//                  } else {
//                     allInOneDto.setGateWaySn(gateWayDevice.getDeviceSn());
//                     return allInOneDto;
//                  }
//               }
//            }
//         }
//      }
//   }
//
//   public Map<Integer, Integer> getDeviceTypeCountMap() {
//      List<DeviceTypeDto> deviceTypeDtos = this.deviceInfoMapper.getDeviceTypeCountMap();
//      return (Map)deviceTypeDtos.stream().collect(Collectors.toMap(DeviceTypeDto::getDeviceType, DeviceTypeDto::getDeviceCount));
//   }
//
//   public List<String> listLocaltionDevices(DeviceSearchDTO deviceSearchDTO) {
//      return this.deviceInfoMapper.listLocaltionDevices(deviceSearchDTO);
//   }
//
//   // $FF: synthetic method
//   private static Object $deserializeLambda$(SerializedLambda lambda) {
//      switch (lambda.getImplMethodName()) {
//         case "getFontSize":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getFontSize;
//            }
//            break;
//         case "getDataStatus":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDataStatus;
//            }
//            break;
//         case "getLineNum":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getLineNum;
//            }
//            break;
//         case "getDelFlag":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/bus/model/BusDeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return BusDeviceInfo::getDelFlag;
//            }
//            break;
//         case "getFontColor":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getFontColor;
//            }
//            break;
//         case "getVersionName":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getVersionName;
//            }
//            break;
//         case "getMealLineId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceBind") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceBind::getMealLineId;
//            }
//            break;
//         case "getVersionCode":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getVersionCode;
//            }
//            break;
//         case "getDeviceId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/bus/model/BusDeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return BusDeviceInfo::getDeviceId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceInfo::getDeviceId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/bus/model/BusDeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return BusDeviceInfo::getDeviceId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceInfo::getDeviceId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceInfo::getDeviceId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceInfo::getDeviceId;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceInfo::getDeviceId;
//            }
//            break;
//         case "getDeviceSn":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfoInSystem") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfoInSystem::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceSn;
//            }
//            break;
//         case "getTerminalSn":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getTerminalSn;
//            }
//            break;
//         case "getStallId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceBind") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceBind::getStallId;
//            }
//            break;
//         case "getDeviceState":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDeviceState;
//            }
//            break;
//         case "getIfDiscount":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getIfDiscount;
//            }
//            break;
//         case "getDeviceType":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDeviceType;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDeviceType;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDeviceType;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDeviceType;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getDeviceType;
//            }
//            break;
//         case "getDeviceNum":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceNum;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceNum;
//            }
//            break;
//         case "getDeviceParentId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceInfo::getDeviceParentId;
//            }
//            break;
//         case "getDeviceName":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDeviceName;
//            }
//            break;
//         case "getTerminalKey":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getTerminalKey;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getTerminalKey;
//            }
//            break;
//         case "getCanteenId":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceBind") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
//               return DeviceBind::getCanteenId;
//            }
//            break;
//         case "getDevicePwd":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//               return DeviceInfo::getDevicePwd;
//            }
//            break;
//         case "getOnlineState":
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getOnlineState;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getOnlineState;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getOnlineState;
//            }
//
//            if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/device/manage/model/DeviceInfo") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
//               return DeviceInfo::getOnlineState;
//            }
//      }
//
//      throw new IllegalArgumentException("Invalid lambda deserialization");
//   }
}
