package com.bonus.canteen.core.device.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.device.manage.controller.deprecated.dto.MacApiUSelectDto;
import com.bonus.canteen.core.device.manage.controller.deprecated.model.MacMachineCounter;
import com.bonus.canteen.core.device.manage.controller.deprecated.vo.CustomShopstallVO;
import com.bonus.canteen.core.device.manage.controller.deprecated.vo.MacMachineApiVO;
import com.bonus.canteen.core.device.manage.controller.deprecated.vo.MachineCounterVO;
import com.bonus.canteen.core.device.manage.controller.deprecated.vo.QueryMacBuffetVO;
import com.bonus.canteen.core.device.manage.dto.DeviceSearchDTO;
import com.bonus.canteen.core.device.manage.vo.DeviceBindVO;
import com.bonus.canteen.core.device.manage.vo.DeviceFullInfoVO;
import com.bonus.canteen.core.device.manage.vo.DeviceInfoVO;
import com.bonus.canteen.core.device.manage.vo.DeviceRecipeVO;

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

public class DeviceDtoConverter {
//   public static DeviceDTO toDeviceDto(MachineCounterDto oldDto) {
//      DeviceDTO deviceDTO = new DeviceDTO();
//      BeanUtil.copyProperties(oldDto, deviceDTO, new String[0]);
//      deviceDTO.setDeviceId(oldDto.getMachineId());
//      deviceDTO.setEffId(oldDto.getEffId());
//      deviceDTO.setDeviceSn(oldDto.getMachineSn());
//      deviceDTO.setDeviceName(oldDto.getMchName());
//      deviceDTO.setDeviceNum(oldDto.getMchNum());
//      deviceDTO.setDeviceModel(oldDto.getMchModel());
//      deviceDTO.setDeviceType(oldDto.getMchType());
//      deviceDTO.setDevicePwd(oldDto.getMchPwd());
//      deviceDTO.setDeviceAddr(oldDto.getMchAddr());
//      deviceDTO.setDeviceKey(oldDto.getMchKey());
//      deviceDTO.setCommMode(oldDto.getCommMode());
//      deviceDTO.setDeviceIp(oldDto.getMchIp());
//      deviceDTO.setDeviceMask(oldDto.getMchMask());
//      deviceDTO.setDeviceMac(oldDto.getMchMac());
//      deviceDTO.setDeviceGateway(oldDto.getMchGateway());
//      deviceDTO.setFirstDns(oldDto.getFirstDns());
//      deviceDTO.setNextDns(oldDto.getNextDns());
//      deviceDTO.setIfQuotaLimit(oldDto.getIfQuotaLimit());
//      deviceDTO.setIfDiscount(oldDto.getIfDiscount());
//      deviceDTO.setIfTimeLimit(oldDto.getIfTimeLimit());
//      deviceDTO.setIfUseCallNum(oldDto.getIfUseCallNum());
//      deviceDTO.setIfEnable(oldDto.getIfEnable());
//      deviceDTO.setImgUrl(oldDto.getImgUrl());
//      deviceDTO.setHeartBeatTime(oldDto.getHeartBeatTime());
//      deviceDTO.setCarouselTime(oldDto.getCarouselTime());
//      deviceDTO.setTitleSlogan(oldDto.getTitleSlogan());
//      deviceDTO.setFontSize(oldDto.getFontSize());
//      deviceDTO.setFontColor(oldDto.getFontColor());
//      deviceDTO.setLineNum(oldDto.getLineNum());
//      deviceDTO.setOncePayAmount(oldDto.getOncePayAmount());
//      deviceDTO.setDetailNumLimit(oldDto.getDetailNumLimit());
//      deviceDTO.setGateDefaultAmount(oldDto.getGateDefaultAmount());
//      if (DeviceStrategy.supportsMultiBind(oldDto.getMchType()) && CollUtil.isNotEmpty(oldDto.getMacBuffetList())) {
//         List<DeviceBindDTO> bindDTOList = CollUtil.newArrayList(new DeviceBindDTO[0]);
//         List<DeviceRecipeDTO> recipeDTOList = CollUtil.newArrayList(new DeviceRecipeDTO[0]);
//         Iterator var4 = oldDto.getMacBuffetList().iterator();
//
//         while(var4.hasNext()) {
//            MacBuffet macBuffet = (MacBuffet)var4.next();
//            long nextId = Id.next();
//            DeviceBindDTO deviceBindDTO = new DeviceBindDTO();
//            deviceBindDTO.setId(nextId);
//            deviceBindDTO.setDeviceId(macBuffet.getMachineId());
//            deviceBindDTO.setCanteenId(oldDto.getCanteenId());
//            deviceBindDTO.setStallId(macBuffet.getShopstallId());
//            deviceBindDTO.setIfUsePrint(macBuffet.getIfUsePrint());
//            bindDTOList.add(deviceBindDTO);
//            if (macBuffet.getRecipeId() != null) {
//               DeviceRecipeDTO deviceRecipeDTO = new DeviceRecipeDTO();
//               deviceRecipeDTO.setId(nextId);
//               deviceRecipeDTO.setDeviceId(macBuffet.getMachineId());
//               deviceRecipeDTO.setCanteenId(oldDto.getCanteenId());
//               deviceRecipeDTO.setStallId(macBuffet.getShopstallId());
//               deviceRecipeDTO.setRecipeId(macBuffet.getRecipeId());
//               recipeDTOList.add(deviceRecipeDTO);
//            }
//         }
//
//         deviceDTO.setBinds(bindDTOList);
//         deviceDTO.setRecipeList(recipeDTOList);
//      } else {
//         DeviceBindDTO deviceBindDTO = new DeviceBindDTO();
//         deviceBindDTO.setDeviceId(oldDto.getMachineId());
//         deviceBindDTO.setCanteenId(oldDto.getCanteenId());
//         deviceBindDTO.setStallId(oldDto.getShopstallId());
//         deviceDTO.setBinds(CollUtil.toList(new DeviceBindDTO[]{deviceBindDTO}));
//         if (oldDto.getRecipeId() != null) {
//            DeviceRecipeDTO deviceRecipeDTO = new DeviceRecipeDTO();
//            deviceRecipeDTO.setDeviceId(oldDto.getMachineId());
//            deviceRecipeDTO.setCanteenId(oldDto.getCanteenId());
//            deviceRecipeDTO.setStallId(oldDto.getShopstallId());
//            deviceRecipeDTO.setRecipeId(oldDto.getRecipeId());
//            deviceDTO.setRecipeList(CollUtil.toList(new DeviceRecipeDTO[]{deviceRecipeDTO}));
//         }
//      }
//
//      if (oldDto.getMacPrinters() != null) {
//         deviceDTO.setPriStatus(oldDto.getMacPrinters().getPriStatus());
//         deviceDTO.setPriKey(oldDto.getMacPrinters().getPriKey());
//      }
//
//      if (CollUtil.isNotEmpty(oldDto.getMacMachineCounters())) {
//         List<DeviceLockerCabinetDTO> cabinetDTOList = (List)oldDto.getMacMachineCounters().stream().map((s) -> {
//            DeviceLockerCabinetDTO cabinetDTO = new DeviceLockerCabinetDTO();
//            cabinetDTO.setCabinetId(s.getId());
//            cabinetDTO.setCabinetNum(s.getCouNum());
//            cabinetDTO.setLockerCount(s.getCouCount());
//            cabinetDTO.setDeviceId(s.getMachineId());
//            return cabinetDTO;
//         }).collect(Collectors.toList());
//         deviceDTO.setCabinets(cabinetDTOList);
//      }
//
//      return deviceDTO;
//   }

   public static MachineCounterVO toMachineCounterVO(DeviceFullInfoVO deviceInfoVO) {
      MachineCounterVO oldVo = new MachineCounterVO();
      BeanUtil.copyProperties(deviceInfoVO, oldVo, new String[0]);
      oldVo.setEffName(deviceInfoVO.getEffName());
      oldVo.setMachineState(deviceInfoVO.getOnlineState());
      oldVo.setDeviceAgreement(deviceInfoVO.getDeviceAgreement());
      oldVo.setId(deviceInfoVO.getDeviceId());
      oldVo.setMachineId(deviceInfoVO.getDeviceId());
      oldVo.setMachineSn(deviceInfoVO.getDeviceSn());
      oldVo.setMchPwd(deviceInfoVO.getDevicePwd());
      oldVo.setMchNum(deviceInfoVO.getDeviceNum());
      oldVo.setMchName(deviceInfoVO.getDeviceName());
      oldVo.setMchAddr(deviceInfoVO.getDeviceAddr());
      oldVo.setMchType(deviceInfoVO.getDeviceType());
      oldVo.setMchModel(deviceInfoVO.getDeviceModel());
      oldVo.setOnlineState(deviceInfoVO.getOnlineState());
      oldVo.setVersionCode(deviceInfoVO.getVersionCode());
      oldVo.setVersionName(deviceInfoVO.getVersionName());
      oldVo.setMchKey(deviceInfoVO.getDeviceKey());
      oldVo.setConsumMode(deviceInfoVO.getConsumMode());
      oldVo.setCommMode(deviceInfoVO.getCommMode());
      oldVo.setMchIp(deviceInfoVO.getDeviceIp());
      oldVo.setMchMask(deviceInfoVO.getDeviceMask());
      oldVo.setMchMac(deviceInfoVO.getDeviceMac());
      oldVo.setMchGateway(deviceInfoVO.getDeviceGateway());
      oldVo.setFirstDns(deviceInfoVO.getFirstDns());
      oldVo.setNextDns(deviceInfoVO.getNextDns());
      oldVo.setDataStatus(deviceInfoVO.getDataStatus());
      oldVo.setOncePayAmount(deviceInfoVO.getOncePayAmount());
      oldVo.setImgUrl(deviceInfoVO.getImgUrl());
      oldVo.setIfQuotaLimit(deviceInfoVO.getIfQuotaLimit());
      oldVo.setIfTimeLimit(deviceInfoVO.getIfTimeLimit());
      oldVo.setIfDiscount(deviceInfoVO.getIfDiscount());
      oldVo.setIfUseCallNum(deviceInfoVO.getIfUseCallNum());
      oldVo.setIfEnable(deviceInfoVO.getIfEnable());
      oldVo.setAmountNotify(deviceInfoVO.getAmountNotify());
      oldVo.setBindingValidTime(deviceInfoVO.getBindingValidTime());
      oldVo.setOrdAutomaticPay(deviceInfoVO.getOrdAutomaticPay());
      oldVo.setIfOffLinePay(deviceInfoVO.getIfOffLinePay());
      oldVo.setAlarmTime(deviceInfoVO.getAlarmTime());
      oldVo.setSpoonWeight(deviceInfoVO.getSpoonWeight());
      oldVo.setHeartBeatTime(deviceInfoVO.getHeartBeatTime());
      oldVo.setCarouselTime(deviceInfoVO.getCarouselTime());
      oldVo.setTitleSlogan(deviceInfoVO.getTitleSlogan());
      oldVo.setFontSize(deviceInfoVO.getFontSize());
      oldVo.setImageMap(deviceInfoVO.getImageMap());
      oldVo.setFontColor(deviceInfoVO.getFontColor());
      oldVo.setLineNum(deviceInfoVO.getLineNum());
      oldVo.setEffId(deviceInfoVO.getEffId());
      oldVo.setTerminalSn(deviceInfoVO.getTerminalSn());
      oldVo.setTerminalKey(deviceInfoVO.getTerminalKey());
      oldVo.setOrdOpenLimit(deviceInfoVO.getOrdOpenLimit());
      oldVo.setDetailNumLimit(deviceInfoVO.getDetailNumLimit());
      oldVo.setRecipeId(deviceInfoVO.getFirstRecipeId());
      oldVo.setRecipeName(deviceInfoVO.getFirstRecipeName());
      oldVo.setGateDefaultAmount(deviceInfoVO.getGateDefaultAmount());
      if (CollUtil.isNotEmpty(deviceInfoVO.getLockerCabinetList())) {
         List<MacMachineCounter> counterList = (List)deviceInfoVO.getLockerCabinetList().stream().map((s) -> {
            MacMachineCounter macMachineCounter = new MacMachineCounter();
            macMachineCounter.setId(s.getCabinetId());
            macMachineCounter.setMachineId(s.getDeviceId());
            macMachineCounter.setMachineSn(deviceInfoVO.getDeviceSn());
            macMachineCounter.setCouNum(s.getCabinetNum());
            macMachineCounter.setCouCount(s.getLockerCount());
            return macMachineCounter;
         }).collect(Collectors.toList());
         oldVo.setMacMachineCounters(counterList);
      }

      oldVo.getMacPrinters().setMachineId(deviceInfoVO.getDeviceId());
      oldVo.getMacPrinters().setPriStatus(deviceInfoVO.getPriStatus());
      oldVo.getMacPrinters().setPriKey(deviceInfoVO.getPriKey());
      if (CollUtil.isNotEmpty(deviceInfoVO.getBindList())) {
         DeviceBindVO firstBind = (DeviceBindVO)deviceInfoVO.getBindList().get(0);
         oldVo.setDiningId(firstBind.getCanteenId());
         oldVo.setCanteenId(firstBind.getCanteenId());
         oldVo.setShopstallId(firstBind.getStallId());
         oldVo.setStname(firstBind.getStallName());
         oldVo.setImgUrl(firstBind.getStallImgUrl());
         oldVo.setStaTime(firstBind.getStallStaTime());
         oldVo.setEndTime(firstBind.getStallEndTime());
         oldVo.setIfOpen(firstBind.getStallIfOpen());
         oldVo.setCanteenName(firstBind.getCanteenName());
         Map<Long, DeviceRecipeVO> deviceRecipeMapById = (Map)deviceInfoVO.getRecipeList().stream().collect(Collectors.toMap(DeviceRecipeVO::getId, Function.identity()));
         List<CustomShopstallVO> customShopstallVOList = (List)deviceInfoVO.getRecipeList().stream().map((s) -> {
            DeviceRecipeVO deviceRecipeVO = (DeviceRecipeVO)deviceRecipeMapById.get(s.getId());
            CustomShopstallVO customShopstallVO = new CustomShopstallVO();
            customShopstallVO.setCanteenId(s.getCanteenId());
            customShopstallVO.setCanteenName(s.getCanteenName());
            customShopstallVO.setShopstallId(s.getStallId());
            customShopstallVO.setShopstallName(s.getStallName());
            customShopstallVO.setRecipeId(deviceRecipeVO != null ? deviceRecipeVO.getRecipeId() : null);
            customShopstallVO.setRecipeName(deviceRecipeVO != null ? deviceRecipeVO.getRecipeName() : null);
            customShopstallVO.setImgUrl(s.getStallImgUrl());
            customShopstallVO.setIfOpen(s.getStallIfOpen());
            customShopstallVO.setStaTime(s.getStallStaTime());
            customShopstallVO.setEndTime(s.getStallEndTime());
            return customShopstallVO;
         }).collect(Collectors.toList());
         oldVo.setCustomShopstallVOList(customShopstallVOList);
         List<QueryMacBuffetVO> buffetVOList = (List)deviceInfoVO.getRecipeList().stream().map((s) -> {
            DeviceRecipeVO deviceRecipeVO = (DeviceRecipeVO)deviceRecipeMapById.get(s.getId());
            QueryMacBuffetVO buffetVO = new QueryMacBuffetVO();
            buffetVO.setMachineId(s.getDeviceId());
            buffetVO.setShopstallId(s.getStallId());
            buffetVO.setStname(s.getStallName());
            buffetVO.setRecipeId(deviceRecipeVO != null ? deviceRecipeVO.getRecipeId() : null);
            buffetVO.setRecipeName(deviceRecipeVO != null ? deviceRecipeVO.getRecipeName() : null);
            buffetVO.setImgUrl(s.getStallImgUrl());
            return buffetVO;
         }).collect(Collectors.toList());
         oldVo.setMacBuffetList(buffetVOList);
      }

      return oldVo;
   }

   public static List<MachineCounterVO> toMachineCounterVO(List<DeviceFullInfoVO> deviceFullInfoVOList) {
      return (List)(CollUtil.isEmpty(deviceFullInfoVOList) ? CollUtil.newArrayList(new MachineCounterVO[0]) : (List)deviceFullInfoVOList.stream().map(DeviceDtoConverter::toMachineCounterVO).collect(Collectors.toList()));
   }

//   public static MacMachineVo toMacMachineVo(DeviceInfoVO deviceInfoVO) {
//      MacMachineVo oldVo = new MacMachineVo();
//      BeanUtil.copyProperties(deviceInfoVO, oldVo, new String[0]);
//      oldVo.setId(deviceInfoVO.getDeviceId());
//      oldVo.setMachineId(deviceInfoVO.getDeviceId());
//      oldVo.setMachineSn(deviceInfoVO.getDeviceSn());
//      oldVo.setMchPwd(deviceInfoVO.getDevicePwd());
//      oldVo.setMchNum(deviceInfoVO.getDeviceNum());
//      oldVo.setMchName(deviceInfoVO.getDeviceName());
//      oldVo.setMchAddr(deviceInfoVO.getDeviceAddr());
//      oldVo.setMchType(deviceInfoVO.getDeviceType());
//      oldVo.setMchModel(deviceInfoVO.getDeviceModel());
//      oldVo.setConsumMode(deviceInfoVO.getConsumMode());
//      oldVo.setCommMode(deviceInfoVO.getCommMode());
//      oldVo.setMchIp(deviceInfoVO.getDeviceIp());
//      oldVo.setMchMask(deviceInfoVO.getDeviceMask());
//      oldVo.setMchMac(deviceInfoVO.getDeviceMac());
//      oldVo.setMchGateway(deviceInfoVO.getDeviceGateway());
//      oldVo.setFirstDns(deviceInfoVO.getFirstDns());
//      oldVo.setNextDns(deviceInfoVO.getNextDns());
//      oldVo.setDataStatus(deviceInfoVO.getDataStatus());
//      oldVo.setOncePayAmount(deviceInfoVO.getOncePayAmount());
//      oldVo.setImgUrl(deviceInfoVO.getImgUrl());
//      oldVo.setIfQuotaLimit(deviceInfoVO.getIfQuotaLimit());
//      oldVo.setIfTimeLimit(deviceInfoVO.getIfTimeLimit());
//      oldVo.setIfDiscount(deviceInfoVO.getIfDiscount());
//      oldVo.setIfUseCallNum(deviceInfoVO.getIfUseCallNum());
//      oldVo.setIfEnable(deviceInfoVO.getIfEnable());
//      oldVo.setAmountNotify(deviceInfoVO.getAmountNotify());
//      oldVo.setBindingValidTime(deviceInfoVO.getBindingValidTime());
//      oldVo.setOrdAutomaticPay(deviceInfoVO.getOrdAutomaticPay());
//      oldVo.setIfOffLinePay(deviceInfoVO.getIfOffLinePay());
//      oldVo.setAlarmTime(deviceInfoVO.getAlarmTime());
//      oldVo.setSpoonWeight(deviceInfoVO.getSpoonWeight());
//      oldVo.setHeartBeatTime(deviceInfoVO.getHeartBeatTime());
//      oldVo.setCarouselTime(deviceInfoVO.getCarouselTime());
//      oldVo.setTitleSlogan(deviceInfoVO.getTitleSlogan());
//      oldVo.setFontSize(deviceInfoVO.getFontSize());
//      oldVo.setFontColor(deviceInfoVO.getFontColor());
//      oldVo.setLineNum(deviceInfoVO.getLineNum());
//      oldVo.setEffId(deviceInfoVO.getEffId());
//      oldVo.setTerminalSn(deviceInfoVO.getTerminalSn());
//      oldVo.setTerminalKey(deviceInfoVO.getTerminalKey());
//      oldVo.setOrdOpenLimit(deviceInfoVO.getOrdOpenLimit());
//      oldVo.setDetailNumLimit(deviceInfoVO.getDetailNumLimit());
//      oldVo.setGateDefaultAmount(deviceInfoVO.getGateDefaultAmount());
//      oldVo.setDiningId(deviceInfoVO.getFirstCanteenId());
//      oldVo.setShopstallId(deviceInfoVO.getFirstShopstallId());
//      oldVo.setRecipeId(deviceInfoVO.getFirstRecipeId());
//      return oldVo;
//   }
//
//   public static List<MacMachineVo> toMacMachineVo(List<DeviceInfoVO> deviceInfoVoList) {
//      return (List)(CollUtil.isEmpty(deviceInfoVoList) ? ListUtil.toList(new MacMachineVo[0]) : (List)deviceInfoVoList.stream().map(DeviceDtoConverter::toMacMachineVo).collect(Collectors.toList()));
//   }
//
//   public static QueryIssueMachineVO toQueryIssueMachineVO(DeviceFullInfoVO deviceInfoVO) {
//      QueryIssueMachineVO oldVo = new QueryIssueMachineVO();
//      oldVo.setMachineId(deviceInfoVO.getDeviceId());
//      oldVo.setMachineSn(deviceInfoVO.getDeviceSn());
//      oldVo.setMchAddr(deviceInfoVO.getDeviceAddr());
//      oldVo.setMchName(deviceInfoVO.getDeviceName());
//      oldVo.setMchName(deviceInfoVO.getDeviceName());
//      oldVo.setConsumMode(deviceInfoVO.getConsumMode());
//      oldVo.setCommMode((long)deviceInfoVO.getCommMode());
//      oldVo.setImgUrl(deviceInfoVO.getImgUrl());
//      oldVo.setFontSize(deviceInfoVO.getFontSize());
//      oldVo.setFontColor(deviceInfoVO.getFontColor());
//      oldVo.setLineNum(deviceInfoVO.getLineNum());
//      if (CollUtil.isNotEmpty(deviceInfoVO.getBindList())) {
//         oldVo.setDiningId(((DeviceBindVO)deviceInfoVO.getBindList().get(0)).getCanteenId());
//         oldVo.setShopstallId(((DeviceBindVO)deviceInfoVO.getBindList().get(0)).getStallId());
//         oldVo.setCanteenName(((DeviceBindVO)deviceInfoVO.getBindList().get(0)).getCanteenName());
//         oldVo.setStname(((DeviceBindVO)deviceInfoVO.getBindList().get(0)).getStallName());
//      }
//
//      oldVo.setRecipeId(deviceInfoVO.getFirstRecipeId());
//      return oldVo;
//   }
//
//   public static List<IssueRecipeDTO> toIssueRecipeDTO(List<DeviceInfoVO> deviceInfoVOList) {
//      return (List)(CollUtil.isEmpty(deviceInfoVOList) ? CollUtil.newArrayList(new IssueRecipeDTO[0]) : (List)deviceInfoVOList.stream().filter((s) -> {
//         return CollUtil.isNotEmpty(s.getBindList());
//      }).map((s) -> {
//         IssueRecipeDTO oldDto = new IssueRecipeDTO();
//         oldDto.setRecipeId(s.getFirstRecipeId());
//         oldDto.setMachineNum(s.getDeviceNum());
//         return oldDto;
//      }).collect(Collectors.toList()));
//   }
//
//   public static DeviceSearchDTO toDeviceSearchDTO(MachineCounterTypeDto oldDto) {
//      DeviceSearchDTO searchDTO = new DeviceSearchDTO();
//      searchDTO.setCanteenId(oldDto.getCanteenId());
//      searchDTO.setStallId(oldDto.getShopstallId());
//      searchDTO.setDeviceSn(oldDto.getMachineSn());
//      searchDTO.setDeviceNum(oldDto.getMchNum());
//      searchDTO.setDeviceName(oldDto.getMchName());
//      searchDTO.setDeviceType(oldDto.getMchType());
//      searchDTO.setDeviceTypeList(oldDto.getMchTypeList());
//      return searchDTO;
//   }

   public static DeviceSearchDTO toDeviceSearchDTO(MacApiUSelectDto oldDto) {
      DeviceSearchDTO searchDTO = new DeviceSearchDTO();
      searchDTO.setCanteenId(oldDto.getCanteenId());
      searchDTO.setStallId(oldDto.getShopstallId());
      searchDTO.setDeviceSn(oldDto.getMachineSn());
      searchDTO.setDeviceNum(oldDto.getMchNum());
      searchDTO.setDeviceType(oldDto.getMchType());
      return searchDTO;
   }

//   public static PayOrderMachineVO toPayOrderMachineVo(DeviceInfo deviceInfo) {
//      PayOrderMachineVO oldVo = new PayOrderMachineVO();
//      oldVo.setMachineId(deviceInfo.getDeviceId());
//      oldVo.setMachineSn(deviceInfo.getDeviceSn());
//      oldVo.setMchNum(deviceInfo.getDeviceNum());
//      oldVo.setMchName(deviceInfo.getDeviceName());
//      oldVo.setMchType(deviceInfo.getDeviceType());
//      return oldVo;
//   }
//
//   public static List<PayOrderMachineVO> toPayOrderMachineVoList(List<DeviceInfo> deviceInfoList) {
//      return (List)(CollUtil.isEmpty(deviceInfoList) ? ListUtil.toList(new PayOrderMachineVO[0]) : (List)deviceInfoList.stream().map(DeviceDtoConverter::toPayOrderMachineVo).collect(Collectors.toList()));
//   }
//
//   public static MacMachineSnAgainstMerchantId toMacMachineSnAgainstMerchantId(DeviceInfoInSystem deviceInfo) {
//      return new MacMachineSnAgainstMerchantId(deviceInfo.getTenantId());
//   }

   public static List<MacMachineApiVO> toMacMachineApiVO(List<DeviceInfoVO> deviceInfoVOList) {
      return (List)(CollUtil.isEmpty(deviceInfoVOList) ? CollUtil.newArrayList(new MacMachineApiVO[0]) : (List)deviceInfoVOList.stream().map(DeviceDtoConverter::toMacMachineApiVO).collect(Collectors.toList()));
   }

   public static MacMachineApiVO toMacMachineApiVO(DeviceInfoVO deviceInfoVO) {
      MacMachineApiVO oldVo = new MacMachineApiVO();
      oldVo.setMachineId(deviceInfoVO.getDeviceId());
      oldVo.setMachineSn(deviceInfoVO.getDeviceSn());
      oldVo.setMchPwd(deviceInfoVO.getDevicePwd());
      oldVo.setMchNum(deviceInfoVO.getDeviceNum());
      oldVo.setMchName(deviceInfoVO.getDeviceName());
      oldVo.setMchAddr(deviceInfoVO.getDeviceAddr());
      oldVo.setSourceType(deviceInfoVO.getDeviceType());
      oldVo.setConsumMode(deviceInfoVO.getConsumMode());
      oldVo.setConsumMode(deviceInfoVO.getConsumMode());
      oldVo.setMchModel(deviceInfoVO.getDeviceModel());
      oldVo.setMchIp(deviceInfoVO.getDeviceIp());
      if (CollUtil.isNotEmpty(deviceInfoVO.getBindList())) {
         oldVo.setCanteenId(((DeviceInfoVO.BindVO)deviceInfoVO.getBindList().get(0)).getCanteenId());
         oldVo.setShopstallId(((DeviceInfoVO.BindVO)deviceInfoVO.getBindList().get(0)).getStallId());
      }

      oldVo.setRecipeId(deviceInfoVO.getFirstRecipeId());
      return oldVo;
   }

//   public static DeviceSearchDTO toDeviceSearchDTO(MachineRecipeRelease oldDto) {
//      DeviceSearchDTO searchDTO = new DeviceSearchDTO();
//      searchDTO.setCanteenId(oldDto.getCanteenId());
//      searchDTO.setStallId(oldDto.getShopstallId());
//      searchDTO.setRecipeId(oldDto.getRecipeId());
//      return searchDTO;
//   }
//
//   public static List<MacMealsCounterDetailVO> toMacMealsCounterDetailVO(List<DeviceLockerVO> deviceLockerVo) {
//      return (List)(CollUtil.isEmpty(deviceLockerVo) ? CollUtil.newArrayList(new MacMealsCounterDetailVO[0]) : (List)deviceLockerVo.stream().map(DeviceDtoConverter::toMacMealsCounterDetailVO).collect(Collectors.toList()));
//   }
//
//   public static MacMealsCounterDetailVO toMacMealsCounterDetailVO(DeviceLockerVO deviceLocker) {
//      MacMealsCounterDetailVO vo = new MacMealsCounterDetailVO();
//      vo.setCounterId(deviceLocker.getLockerId());
//      vo.setCounterNum(deviceLocker.getLockerNum());
//      vo.setMachineId(deviceLocker.getDeviceId());
//      vo.setOrdId(deviceLocker.getOrdId());
//      vo.setCounterStatus(deviceLocker.getLockerStatus());
//      vo.setActivate(deviceLocker.getActivate());
//      return vo;
//   }
//
//   public static DeviceWeighAlarmInfoSearchDto toDeviceWeighAlarmInfoSearchDto(MacWeighAlarmInfoSelectDto dto) {
//      DeviceWeighAlarmInfoSearchDto oldDto = new DeviceWeighAlarmInfoSearchDto();
//      oldDto.setDeviceSn(dto.getMachineSn());
//      oldDto.setDeviceNum(dto.getMachineNum());
//      oldDto.setStallId(dto.getShopstallId());
//      oldDto.setCanteenId(dto.getCanteenId());
//      return oldDto;
//   }
//
//   public static MacWeighAlarmInfoVo toMacWeighAlarmInfoVo(DeviceWeighAlarmInfo deviceWeighAlarmInfo) {
//      MacWeighAlarmInfoVo oldVo = new MacWeighAlarmInfoVo();
//      oldVo.setId(deviceWeighAlarmInfo.getAlarmId());
//      oldVo.setMachineNum(deviceWeighAlarmInfo.getDeviceNum());
//      oldVo.setMachineName(deviceWeighAlarmInfo.getDeviceName());
//      oldVo.setMachineSn(deviceWeighAlarmInfo.getDeviceSn());
//      oldVo.setShopstallName(deviceWeighAlarmInfo.getStallName());
//      oldVo.setShopstallId(deviceWeighAlarmInfo.getStallId());
//      oldVo.setCanteenName(deviceWeighAlarmInfo.getCanteenName());
//      oldVo.setCanteenId(deviceWeighAlarmInfo.getCanteenId());
//      oldVo.setAlarmTime(deviceWeighAlarmInfo.getAlarmTime());
//      oldVo.setAlarmType(deviceWeighAlarmInfo.getAlarmType());
//      oldVo.setCrby(deviceWeighAlarmInfo.getCrby());
//      oldVo.setCrtime(deviceWeighAlarmInfo.getCrtime());
//      return oldVo;
//   }
//
//   public static List<MacWeighAlarmInfoVo> toMacWeighAlarmInfoVo(List<DeviceWeighAlarmInfo> deviceWeighAlarmInfoList) {
//      return (List)(CollUtil.isEmpty(deviceWeighAlarmInfoList) ? CollUtil.newArrayList(new MacWeighAlarmInfoVo[0]) : (List)deviceWeighAlarmInfoList.stream().map(DeviceDtoConverter::toMacWeighAlarmInfoVo).collect(Collectors.toList()));
//   }
//
//   public static DeviceWeighAlarmInfoDTO toDeviceWeighAlarmInfo(MacWeighAlarmInfoDto oldDto) {
//      DeviceWeighAlarmInfoDTO dto = new DeviceWeighAlarmInfoDTO();
//      dto.setDeviceNum(oldDto.getMachineNum());
//      dto.setDeviceName(oldDto.getMachineName());
//      dto.setDeviceSn(oldDto.getMachineSn());
//      dto.setStallName(oldDto.getShopstallName());
//      dto.setStallId(oldDto.getShopstallId());
//      dto.setCanteenName(oldDto.getCanteenName());
//      dto.setCanteenId(oldDto.getCanteenId());
//      dto.setAlarmTime(oldDto.getAlarmTime());
//      dto.setAlarmType(oldDto.getAlarmType());
//      return dto;
//   }
//
//   public static List<CustomShopstallVO> toCustomShopstallVO(List<DeviceBindVO> deviceBindVoList, List<DeviceRecipeVO> deviceRecipeVoList) {
//      if (CollUtil.isEmpty(deviceBindVoList)) {
//         return CollUtil.newArrayList(new CustomShopstallVO[0]);
//      } else {
//         Map<Long, DeviceRecipeVO> deviceRecipeMapByStId = (Map)deviceRecipeVoList.stream().collect(Collectors.toMap(DeviceRecipeVO::getStallId, Function.identity()));
//         return (List)deviceBindVoList.stream().map((s) -> {
//            DeviceRecipeVO deviceRecipeVO = (DeviceRecipeVO)deviceRecipeMapByStId.get(s.getStallId());
//            CustomShopstallVO customShopstallVO = new CustomShopstallVO();
//            customShopstallVO.setCanteenId(s.getCanteenId());
//            customShopstallVO.setCanteenName(s.getCanteenName());
//            customShopstallVO.setShopstallId(s.getStallId());
//            customShopstallVO.setShopstallName(s.getStallName());
//            customShopstallVO.setIfUsePrint(s.getIfUsePrint());
//            customShopstallVO.setImgUrl(s.getStallImgUrl());
//            customShopstallVO.setIfOpen(s.getStallIfOpen());
//            customShopstallVO.setStaTime(s.getStallStaTime());
//            customShopstallVO.setEndTime(s.getStallEndTime());
//            customShopstallVO.setRecipeId(deviceRecipeVO != null ? deviceRecipeVO.getRecipeId() : null);
//            customShopstallVO.setRecipeName(deviceRecipeVO != null ? deviceRecipeVO.getRecipeName() : null);
//            return customShopstallVO;
//         }).collect(Collectors.toList());
//      }
//   }
//
//   public static List<DeviceIssueDTO> toDeviceIssueDTO(List<MacIssue> oldDtoList) {
//      return (List)(CollUtil.isEmpty(oldDtoList) ? CollUtil.newArrayList(new DeviceIssueDTO[0]) : (List)oldDtoList.stream().map((s) -> {
//         DeviceIssueDTO dto = new DeviceIssueDTO();
//         dto.setDeviceId(s.getMachineId());
//         dto.setFontColor(s.getFontColor());
//         dto.setFontSize(s.getFontSize());
//         dto.setLineNum(s.getLineNum());
//         return dto;
//      }).collect(Collectors.toList()));
//   }
//
//   public static DeviceLockerDisabledDTO toDeviceLockerDisabledDTO(MacMealsCounterDisabledDTO oldDto) {
//      DeviceLockerDisabledDTO dto = new DeviceLockerDisabledDTO();
//      dto.setDeviceId(oldDto.getMachineId());
//      dto.setLockerNum(oldDto.getCounterNum());
//      dto.setActivate(oldDto.getActivate());
//      return dto;
//   }
}
