package com.bonus.canteen.core.supply.purchase.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.supply.purchase.api.DrpAuthorityPurchaseApi;
import com.bonus.canteen.core.supply.purchase.constants.*;
import com.bonus.canteen.core.supply.purchase.domain.bo.*;
import com.bonus.canteen.core.supply.purchase.domain.param.DrpSupplierQueryDTO;
import com.bonus.canteen.core.supply.purchase.domain.vo.*;
import com.bonus.canteen.core.supply.purchase.mapper.*;
import com.bonus.canteen.core.supply.purchase.service.DrpPurchaseSupplierQualificationService;
import com.bonus.canteen.core.supply.purchase.service.DrpPurchaseSupplierService;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.houqin.i18n.I18n;
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;

@Service
public class DrpPurchaseSupplierServiceImpl extends ServiceImpl<DrpPurchaseSupplierMapper, DrpSupplier> implements DrpPurchaseSupplierService {
   private static final Logger log = LoggerFactory.getLogger(DrpPurchaseSupplierServiceImpl.class);
//   @Autowired
//   @Lazy
//   private DrpSupplierCategoryMapper drpSupplierCategoryMapper;
//   @Autowired
//   @Lazy
//   private DrpSupplierCategoryService drpSupplierCategoryService;
//   @Autowired
//   @Lazy
//   private DrpSupplierQualificationMapper drpSupplierQualificationMapper;
   @Autowired
   @Lazy
   private DrpPurchaseSupplierQualificationService drpPurchaseSupplierQualificationService;
//   @Autowired
//   @Lazy
//   private DrpInquiryMapper drpInquiryMapper;
//   @Autowired
//   @Lazy
//   private DrpOrderGoodsMapper drpOrderGoodsMapper;
//   @Autowired
//   @Lazy
//   private DrpIntoDetailMapper drpIntoDetailMapper;
//   @Autowired
//   @Lazy
//   private DrpMaterialWinBidRecordsMapper drpMaterialWinBidRecordsMapper;
//   @Autowired
//   @Lazy
//   private DrpMenuMaterialSupplierMapper drpMenuMaterialSupplierMapper;
   @Autowired
   @Lazy
   private DrpAuthorityPurchaseApi drpAuthorityPurchaseApi;
//   @Autowired
//   @Lazy
//   private DrpSupplierDeliverService drpSupplierDeliverService;
//   @Autowired
//   @Lazy
//   private DrpSupplierDeliverMapper drpSupplierDeliverMapper;

//   @Transactional(
//      rollbackFor = {Exception.class}
//   )
//   public void addDrpSupplier(DrpSupplierAddDTO content) {
//      List<DrpSupplier> check = ((DrpSupplierMapper)this.baseMapper).selectList(((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpSupplier.class).eq(DrpSupplier::getSupplierName, content.getSupplierName())).eq(DrpSupplier::getDelFlag, DelFlagEnum.DEL_FALSE.key())).select(new SFunction[]{DrpSupplier::getSupplierId}));
//      if (CollUtil.isNotEmpty(check)) {
//         throw new LeException(I18n.getMessage("drp.supplier-name-have", new Object[0]));
//      } else {
//         if (ObjectUtil.isNotEmpty(content.getSupplierUserId())) {
//            Long checkSupplierUserId = ((DrpSupplierMapper)this.baseMapper).selectCount((Wrapper)Wrappers.lambdaQuery(DrpSupplier.class).eq(DrpSupplier::getSupplierUserId, content.getSupplierUserId()));
//            if (checkSupplierUserId > 0L) {
//               throw new LeException(I18n.getMessage("drp.supplier-is-bind", new Object[0]));
//            }
//         }
//
//         DrpSupplier supplier = new DrpSupplier();
//         BeanUtil.copyProperties(content, supplier, new String[0]);
//         Long supplierId = Id.next();
//         supplier.setSupplierId(supplierId);
//         if (CollUtil.isNotEmpty(content.getCategoryIdList())) {
//            this.insertSupplierCategoryBatch(content.getCategoryIdList(), supplierId);
//         }
//
//         String maxSupplierNumStr = ((DrpSupplierMapper)this.baseMapper).getMaxSupplierNum(DelFlagEnum.DEL_FALSE.key(), DrpBusinessConstants.SUPPLIER_NUM_LENGTH);
//         String supplierNum;
//         if (CharSequenceUtil.isBlank(maxSupplierNumStr)) {
//            supplierNum = "000001";
//         } else {
//            supplierNum = String.format("%06d", Integer.parseInt(maxSupplierNumStr) + 1);
//         }
//
//         supplier.setSupplierNum(supplierNum);
//         supplier.setStatus(DrpSupplierStatusEnum.NORMAL.key());
//         supplier.setDelFlag(DelFlagEnum.DEL_FALSE.key());
//         if (CollUtil.isNotEmpty(content.getAttachmentList())) {
//            supplier.setAttachment(JSONObject.toJSONString(content.getAttachmentList()));
//         }
//
//         ((DrpSupplierMapper)this.baseMapper).insert(supplier);
//         if (CollUtil.isNotEmpty(content.getDeliverVOList())) {
//            content.getDeliverVOList().forEach((d) -> {
//               d.setSupplierId(supplierId);
//               this.drpSupplierDeliverService.add(d);
//            });
//         }
//
//         List<DrpSupplierQualification> drpSupplierQualificationList = new ArrayList();
//         Iterator var8 = content.getMainQualificationList().iterator();
//
//         DrpSupplierQualificationSaveDTO drpSupplierQualificationSaveDTO;
//         DrpSupplierQualification drpSupplierQualification;
//         while(var8.hasNext()) {
//            drpSupplierQualificationSaveDTO = (DrpSupplierQualificationSaveDTO)var8.next();
//            drpSupplierQualification = new DrpSupplierQualification();
//            BeanUtil.copyProperties(drpSupplierQualificationSaveDTO, drpSupplierQualification, new String[0]);
//            drpSupplierQualification.setSupplierId(supplierId);
//            drpSupplierQualification.setMainFlag(DrpQuantityMainFlagEnum.MAIN.getKey());
//            drpSupplierQualificationList.add(drpSupplierQualification);
//         }
//
//         this.drpSupplierQualificationService.saveBatch(drpSupplierQualificationList);
//         if (!CollUtil.isEmpty(content.getOtherQualificationList())) {
//            drpSupplierQualificationList.clear();
//            var8 = content.getOtherQualificationList().iterator();
//
//            while(var8.hasNext()) {
//               drpSupplierQualificationSaveDTO = (DrpSupplierQualificationSaveDTO)var8.next();
//               drpSupplierQualification = new DrpSupplierQualification();
//               BeanUtil.copyProperties(drpSupplierQualificationSaveDTO, drpSupplierQualification, new String[0]);
//               drpSupplierQualification.setSupplierId(supplierId);
//               drpSupplierQualification.setMainFlag(DrpQuantityMainFlagEnum.OTHER.getKey());
//               drpSupplierQualificationList.add(drpSupplierQualification);
//            }
//
//            this.drpSupplierQualificationService.saveBatch(drpSupplierQualificationList);
//         }
//      }
//   }
//
//   public Page<DrpSupplierPageVO> getDrpSupplierPage(DrpSupplierPageDTO content) {
//      if (CharSequenceUtil.isNotEmpty(content.getLinkman())) {
//         content.setLinkman(LeBeanUtil.fieldLikeHandle(content.getLinkman()));
//      }
//
//      if (CharSequenceUtil.isNotEmpty(content.getSupplierName())) {
//         content.setSupplierName(LeBeanUtil.fieldLikeHandle(content.getSupplierName()));
//      }
//
//      Page<DrpSupplierPageVO> resultPage = new Page(content.getCurrent(), content.getSize());
//      resultPage = ((DrpSupplierMapper)this.baseMapper).selectAllList(resultPage, content, DelFlagEnum.DEL_FALSE.key());
//      List<DrpSupplierPageVO> detailList = resultPage.getRecords();
//      if (CollUtil.isEmpty(detailList)) {
//         return resultPage;
//      } else {
//         Iterator var4 = detailList.iterator();
//
//         while(var4.hasNext()) {
//            DrpSupplierPageVO item = (DrpSupplierPageVO)var4.next();
//            QueryWrapper<DrpSupplierCategory> queryWrapper = new QueryWrapper();
//            queryWrapper.eq("dsc.supplier_id", item.getSupplierId());
//            List<CategoryModel> categoryList = this.drpSupplierCategoryMapper.selectNameBySupplier(queryWrapper);
//            if (CollUtil.isNotEmpty(categoryList)) {
//               categoryList = (List)categoryList.stream().filter((a) -> {
//                  return !ObjectUtil.isNull(a);
//               }).collect(Collectors.toList());
//            }
//
//            item.setCategoryModelList(categoryList);
//            List<DrpSupplierDeliverVO> deliverVOList = Lists.newArrayList();
//            this.drpSupplierDeliverMapper.selectList((Wrapper)Wrappers.lambdaQuery(DrpSupplierDeliver.class).eq(DrpSupplierDeliver::getSupplierId, item.getSupplierId())).forEach((d) -> {
//               DrpSupplierDeliverVO drpSupplierDeliverDTO = new DrpSupplierDeliverVO();
//               BeanUtil.copyProperties(d, drpSupplierDeliverDTO, new String[0]);
//               deliverVOList.add(drpSupplierDeliverDTO);
//            });
//            item.setDeliverVOList(deliverVOList);
//            List<DrpSupplierQualification> qualificationList = this.drpSupplierQualificationService.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpSupplierQualification.class).eq(DrpSupplierQualification::getSupplierId, item.getSupplierId())).eq(DrpSupplierQualification::getMainFlag, DrpQuantityMainFlagEnum.MAIN.getKey()));
//            List<DrpSupplierQualificationDetailPageVO> qualificationDetailPageVOList = BeanUtil.copyToList(qualificationList, DrpSupplierQualificationDetailPageVO.class);
//            item.setMainQualificationList(qualificationDetailPageVOList);
//         }
//
//         return resultPage;
//      }
//   }
//
//   @Transactional(
//      rollbackFor = {Exception.class}
//   )
//   public void editDrpSupplier(DrpSupplierEditDTO content) {
//      List<DrpSupplier> check = ((DrpSupplierMapper)this.baseMapper).selectList(((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpSupplier.class).eq(DrpSupplier::getSupplierName, content.getSupplierName())).eq(DrpSupplier::getDelFlag, DelFlagEnum.DEL_FALSE.key())).ne(DrpSupplier::getSupplierId, content.getSupplierId())).select(new SFunction[]{DrpSupplier::getSupplierId}));
//      if (CollUtil.isNotEmpty(check)) {
//         throw new LeException(I18n.getMessage("drp.supplier-name-have", new Object[0]));
//      } else {
//         if (ObjectUtil.isNotEmpty(content.getSupplierUserId())) {
//            Long checkSupplierUserId = ((DrpSupplierMapper)this.baseMapper).selectCount((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpSupplier.class).eq(DrpSupplier::getSupplierUserId, content.getSupplierUserId())).eq(DrpSupplier::getDelFlag, DelFlagEnum.DEL_FALSE.key())).ne(DrpSupplier::getSupplierId, content.getSupplierId()));
//            if (checkSupplierUserId > 0L) {
//               throw new LeException(I18n.getMessage("drp.supplier-is-bind", new Object[0]));
//            }
//         }
//
//         DrpSupplier supplier = new DrpSupplier();
//         BeanUtil.copyProperties(content, supplier, new String[0]);
//         this.drpSupplierCategoryService.remove((Wrapper)Wrappers.lambdaQuery(DrpSupplierCategory.class).eq(DrpSupplierCategory::getSupplierId, content.getSupplierId()));
//         if (CollUtil.isNotEmpty(content.getCategoryIdList())) {
//            this.insertSupplierCategoryBatch(content.getCategoryIdList(), content.getSupplierId());
//         }
//
//         supplier.setDelFlag(DelFlagEnum.DEL_FALSE.key());
//         if (CollUtil.isNotEmpty(content.getAttachmentList())) {
//            supplier.setAttachment(JSONObject.toJSONString(content.getAttachmentList()));
//         }
//
//         if (CollUtil.isNotEmpty(content.getDeliverVOList())) {
//            this.drpSupplierDeliverMapper.delete((Wrapper)Wrappers.lambdaQuery(DrpSupplierDeliver.class).eq(DrpSupplierDeliver::getSupplierId, supplier.getSupplierId()));
//            content.getDeliverVOList().forEach((d) -> {
//               d.setSupplierId(supplier.getSupplierId());
//               this.drpSupplierDeliverService.add(d);
//            });
//         } else {
//            this.drpSupplierDeliverMapper.delete((Wrapper)Wrappers.lambdaQuery(DrpSupplierDeliver.class).eq(DrpSupplierDeliver::getSupplierId, supplier.getSupplierId()));
//         }
//
//         ((DrpSupplierMapper)this.baseMapper).update(supplier, (Wrapper)Wrappers.lambdaQuery(DrpSupplier.class).eq(DrpSupplier::getSupplierId, content.getSupplierId()));
//         if (ObjectUtil.isEmpty(content.getSupplierUserId())) {
//            ((DrpSupplierMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DrpSupplier.class).eq(DrpSupplier::getSupplierId, content.getSupplierId())).set(DrpSupplier::getSupplierUserId, (Object)null));
//         }
//
//         Iterator var4 = content.getMainQualificationList().iterator();
//
//         DrpSupplierQualification drpSupplierQualification;
//         while(var4.hasNext()) {
//            DrpSupplierQualificationUpdateDTO drpSupplierQualificationUpdateDTO = (DrpSupplierQualificationUpdateDTO)var4.next();
//            drpSupplierQualification = new DrpSupplierQualification();
//            BeanUtil.copyProperties(drpSupplierQualificationUpdateDTO, drpSupplierQualification, new String[0]);
//            this.drpSupplierQualificationService.updateById(drpSupplierQualification);
//         }
//
//         if (CollUtil.isNotEmpty(content.getOtherQualificationList())) {
//            this.drpSupplierQualificationMapper.delete((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpSupplierQualification.class).eq(DrpSupplierQualification::getSupplierId, content.getSupplierId())).eq(DrpSupplierQualification::getMainFlag, DrpQuantityMainFlagEnum.OTHER.getKey()));
//            var4 = content.getOtherQualificationList().iterator();
//
//            while(var4.hasNext()) {
//               DrpSupplierQualificationSaveDTO drpSupplierQualificationSaveDTO = (DrpSupplierQualificationSaveDTO)var4.next();
//               drpSupplierQualification = new DrpSupplierQualification();
//               BeanUtil.copyProperties(drpSupplierQualificationSaveDTO, drpSupplierQualification, new String[0]);
//               drpSupplierQualification.setSupplierId(supplier.getSupplierId());
//               drpSupplierQualification.setMainFlag(DrpQuantityMainFlagEnum.OTHER.getKey());
//               this.drpSupplierQualificationService.save(drpSupplierQualification);
//            }
//         }
//
//      }
//   }
//
//   @Transactional(
//      rollbackFor = {Exception.class}
//   )
//   public void removeBySupplierId(Long supplierId) {
//      if (ObjectUtil.isEmpty(supplierId)) {
//         log.info("***[库存中心_供应商管理]_删除供应商信息_传入的供应商id为空************");
//         throw new LeException(I18n.getMessage("drp.supplier-id-is-null", new Object[0]));
//      } else {
//         ((DrpSupplierMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DrpSupplier.class).eq(DrpSupplier::getSupplierId, supplierId)).set(DrpSupplier::getDelFlag, DelFlagEnum.DEL_TRUE.key())).set(DrpSupplier::getSupplierUserId, (Object)null));
//      }
//   }
//
//   public void editDrpSupplierStatus(DrpSupplierEditStatusDTO content) {
//      String username = SecurityUtils.getUser().getUsername();
//      ((DrpSupplierMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(DrpSupplier.class).eq(DrpSupplier::getSupplierId, content.getSupplierId())).set(DrpSupplier::getStatus, content.getStatus())).set(DrpSupplier::getUpby, username));
//   }

   public List<DrpSupplierVO> listSupplier(DrpSupplierQueryDTO content) {
      content.setAreaIdList(content.getAreaIdList());
      return this.baseMapper.listSupplier(DrpSupplierStatusEnum.NORMAL.key(), DelFlagEnum.DEL_FALSE.key(), content);
   }

//   public List<DrpCompariseSupplierQualificationPageVO> compariseSupplierQualification(DrpCompariseSupplierQualificationPageDTO content) {
//      List<DrpCompariseSupplierQualificationPageVO> resultList = ((DrpSupplierMapper)this.baseMapper).pageCompariseSupplierQualification(content, DelFlagEnum.DEL_FALSE.key());
//      Iterator var3 = resultList.iterator();
//
//      while(true) {
//         DrpCompariseSupplierQualificationPageVO result;
//         List drpSupplierQualificationList;
//         do {
//            if (!var3.hasNext()) {
//               return resultList;
//            }
//
//            result = (DrpCompariseSupplierQualificationPageVO)var3.next();
//            QueryWrapper<DrpSupplierCategory> queryWrapper = new QueryWrapper();
//            queryWrapper.eq("dsc.supplier_id", result.getSupplierId());
//            List<CategoryModel> categoryList = this.drpSupplierCategoryMapper.selectNameBySupplier(queryWrapper);
//            if (CollUtil.isNotEmpty(categoryList)) {
//               categoryList = (List)categoryList.stream().filter((a) -> {
//                  return !ObjectUtil.isNull(a);
//               }).collect(Collectors.toList());
//            }
//
//            result.setCategoryModelList(categoryList);
//            drpSupplierQualificationList = this.drpSupplierQualificationMapper.selectList(((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpSupplierQualification.class).eq(DrpSupplierQualification::getSupplierId, result.getSupplierId())).eq(DrpSupplierQualification::getMainFlag, DrpQuantityMainFlagEnum.MAIN.getKey())).select(new SFunction[]{DrpSupplierQualification::getQualificationName, DrpSupplierQualification::getValidity}));
//         } while(!CollUtil.isNotEmpty(drpSupplierQualificationList));
//
//         Iterator var8 = drpSupplierQualificationList.iterator();
//
//         while(var8.hasNext()) {
//            DrpSupplierQualification drpSupplierQualification = (DrpSupplierQualification)var8.next();
//            switch (drpSupplierQualification.getQualificationName()) {
//               case "营业执照":
//                  result.setBusinessLicenseDate(drpSupplierQualification.getValidity());
//                  break;
//               case "食品经营许可证":
//                  result.setFoodLicenseDate(drpSupplierQualification.getValidity());
//                  break;
//               case "HACCP认证":
//                  result.setHACCPDate(drpSupplierQualification.getValidity());
//                  break;
//               case "烟草经营许可证":
//                  result.setTobaccoLicenseDate(drpSupplierQualification.getValidity());
//                  break;
//               case "ISO9001国际质量体系认证":
//                  result.setISO9001Date(drpSupplierQualification.getValidity());
//            }
//         }
//      }
//   }
//
//   public List<DrpSupplyStatisticsPageVO> supplyStatistics(DrpSupplyStatisticsPageDTO content) {
//      LocalDateTime startTime = content.getStartTime().atTime(0, 0, 0);
//      LocalDateTime endTime = content.getEndTime().atTime(23, 59, 59);
//      long checkDays = Duration.between(startTime, endTime).toDays();
//      if (checkDays > 366L) {
//         throw new LeException(I18n.getMessage("drp.select-period-not-over-year", new Object[0]));
//      } else {
//         List<DrpSupplyStatisticsPageVO> resultList = ((DrpSupplierMapper)this.baseMapper).supplyStatistics(content, DelFlagEnum.DEL_FALSE.key());
//         Iterator var7 = resultList.iterator();
//
//         while(var7.hasNext()) {
//            DrpSupplyStatisticsPageVO result = (DrpSupplyStatisticsPageVO)var7.next();
//            SupplierBidTimesAndAmountModel supplierBidTimesAndAmountModel = this.drpInquiryMapper.selectBidTimesAndAmount(result.getSupplierId(), content);
//            result.setBidNumbers(supplierBidTimesAndAmountModel.getBidNumbers());
//            result.setCumulativeBidAmount(supplierBidTimesAndAmountModel.getCumulativeBidAmount());
//            SupplierLastBidInfoModel supplierLastBidInfoModel = this.drpInquiryMapper.selectLastBidInfo(result.getSupplierId(), content, DrpInquiryStatusEnum.ALREADY_QUOTE.key());
//            if (ObjectUtil.isNotEmpty(supplierLastBidInfoModel)) {
//               result.setLastBidDate(supplierLastBidInfoModel.getLastBidDate());
//               result.setLastBidAmount(supplierLastBidInfoModel.getLastBidAmount());
//            }
//
//            BigDecimal deliveryQualifiedRate = this.drpIntoDetailMapper.getDeliveryQualifiedRate(result.getSupplierId(), content.getStartTime(), content.getEndTime(), DrpIntoInventoryStatusEnum.COMMIT.key());
//            result.setDeliveryPassRate(deliveryQualifiedRate);
//            DrpOrderNumAndAmountModel drpOrderNumAndAmountModel = this.drpOrderGoodsMapper.selectOrderNumAndAmount(result.getSupplierId(), content, DrpOrderGoodsStatusEnum.IS_COMMIT.getKey());
//            if (ObjectUtil.isNotEmpty(drpOrderNumAndAmountModel)) {
//               result.setOrderNum(drpOrderNumAndAmountModel.getOrderNum());
//               result.setOrderAmount(drpOrderNumAndAmountModel.getOrderAmount());
//            }
//         }
//
//         return resultList;
//      }
//   }

   public DrpSupplierMainInfoVO getMainInfoById(Long supplierId) {
      if (ObjectUtil.isEmpty(supplierId)) {
         throw new ServiceException("供应商id为空");
      } else {
         DrpSupplierMainInfoVO drpSupplierMainInfoVO = this.baseMapper.getSupplierMainInfoById(supplierId);
         List<DrpSupplierQualification> qualificationList = this.drpPurchaseSupplierQualificationService.list((Wrappers.lambdaQuery(DrpSupplierQualification.class).eq(DrpSupplierQualification::getSupplierId, supplierId)).eq(DrpSupplierQualification::getMainFlag, DrpQuantityMainFlagEnum.MAIN.getKey()));
         List<DrpSupplierQualificationDetailPageVO> qualificationDetailPageVOList = BeanUtil.copyToList(qualificationList, DrpSupplierQualificationDetailPageVO.class);
         drpSupplierMainInfoVO.setMainQualificationList(qualificationDetailPageVOList);
         return drpSupplierMainInfoVO;
      }
   }
//
//   public Map<Long, List<DrpSupplierVO>> supplierByMaterialId(DrpSupplierDTO content) {
//      List<DrpSupplierVO> listSupplier = ((DrpSupplierMapper)this.baseMapper).listSupplier(DrpSupplierStatusEnum.NORMAL.key(), DelFlagEnum.DEL_FALSE.key(), new DrpSupplierQueryDTO());
//      Map<Long, DrpSupplierVO> drpSupplierVOMap = (Map)listSupplier.stream().collect(Collectors.toMap(DrpSupplierVO::getSupplierId, Function.identity()));
//      Map<Long, List<DrpSupplierVO>> returnMap = Maps.newHashMap();
//      if (CollUtil.isNotEmpty(content.getCategoryIds())) {
//         this.packageData(content.getCategoryIds(), drpSupplierVOMap, returnMap);
//         return returnMap;
//      } else {
//         return returnMap;
//      }
//   }
//
//   public DrpSupplierTotalVO getTotal() {
//      return ((DrpSupplierMapper)this.baseMapper).queryTotal();
//   }
//
//   protected void packageData(List<Long> categoryIdList, Map<Long, DrpSupplierVO> drpSupplierVOMap, Map<Long, List<DrpSupplierVO>> returnMap) {
//      List<DrpSupplierCategory> menuMaterialCategoryList = this.drpSupplierCategoryMapper.selectList(Wrappers.lambdaQuery(DrpSupplierCategory.class).in(CollUtil.isNotEmpty(categoryIdList), DrpSupplierCategory::getCategoryId, categoryIdList));
//      Map<Long, List<DrpSupplierCategory>> listMap = (Map)menuMaterialCategoryList.stream().collect(Collectors.groupingBy(DrpSupplierCategory::getCategoryId));
//      if (CollUtil.isNotEmpty(listMap)) {
//         listMap.forEach((key, value) -> {
//            List<DrpSupplierVO> drpSupplierVOList = Lists.newArrayList();
//            if (CollUtil.isNotEmpty(value)) {
//               value.forEach((d) -> {
//                  if (drpSupplierVOMap.get(d.getSupplierId()) != null) {
//                     drpSupplierVOList.add((DrpSupplierVO)drpSupplierVOMap.get(d.getSupplierId()));
//                  }
//
//               });
//            }
//
//            returnMap.put(key, drpSupplierVOList);
//         });
//      }
//
//   }
//
//   protected void insertSupplierCategoryBatch(List<Long> categoryIdList, Long supplierId) {
//      List<DrpSupplierCategory> supplierCategoryList = new ArrayList();
//      Iterator var4 = categoryIdList.iterator();
//
//      while(var4.hasNext()) {
//         Long categoryId = (Long)var4.next();
//         DrpSupplierCategory supplierCategory = new DrpSupplierCategory();
//         supplierCategory.setSupplierId(supplierId);
//         supplierCategory.setCategoryId(categoryId);
//         supplierCategoryList.add(supplierCategory);
//      }
//
//      this.drpSupplierCategoryService.saveBatch(supplierCategoryList);
//   }
//
//   public List<DrpMaterialSupplierVO> getMaterialSupplier(DrpMaterialInfoDTO content) {
//      List drpMaterialSupplierList;
//      if (!ObjectUtil.isNull(content.getConfigType()) && !ObjectUtil.equal(content.getConfigType(), 1)) {
//         PageMethod.startPage(content);
//         drpMaterialSupplierList = ((DrpSupplierMapper)this.baseMapper).getCategorySupplier(content);
//      } else {
//         PageMethod.startPage(content);
//         drpMaterialSupplierList = this.drpMaterialWinBidRecordsMapper.getMaterialSupplier(content);
//         if (CollUtil.isEmpty(drpMaterialSupplierList)) {
//            return drpMaterialSupplierList;
//         }
//
//         List<DrpMaterialBidRecordsSupplierVO> drpMaterialBidRecordsSupplierVOS = this.drpMaterialWinBidRecordsMapper.listSupplierPriceByMaterialIdList((List)drpMaterialSupplierList.stream().map(DrpMaterialSupplierVO::getMaterialId).collect(Collectors.toList()));
//         Map<Long, List<DrpMaterialBidRecordsSupplierVO>> collect = (Map)drpMaterialBidRecordsSupplierVOS.stream().collect(Collectors.groupingBy(DrpMaterialBidRecordsSupplierVO::getMaterialId));
//         List<MaterialAndUnitDTO> materialAndUnitDTOS = (List)drpMaterialSupplierList.stream().map((d) -> {
//            return (new MaterialAndUnitDTO()).setMaterialId(d.getMaterialId()).setUnitId(d.getUnitId());
//         }).collect(Collectors.toList());
//         List<DrpLastOrderGoodsVO> lastOrderGoodsPriceList = this.drpMaterialWinBidRecordsMapper.getLastOrderGoodsPriceList(materialAndUnitDTOS, content.getAreaId());
//         Map<String, DrpLastOrderGoodsVO> orderGoodsVOMap = (Map)lastOrderGoodsPriceList.stream().collect(Collectors.toMap((d) -> {
//            Long var10000 = d.getMaterialId();
//            return "" + var10000 + "-" + d.getUnitId();
//         }, Function.identity(), (k1, k2) -> {
//            return k1;
//         }));
//         if (CollUtil.isNotEmpty(drpMaterialSupplierList)) {
//            drpMaterialSupplierList.forEach((d) -> {
//               List<DrpMaterialBidRecordsSupplierVO> detailList = (List)collect.get(d.getMaterialId());
//               List<DrpSupplierModel> nearestSupplierList = Lists.newArrayList();
//               if (CollUtil.isNotEmpty(detailList)) {
//                  detailList.forEach((e) -> {
//                     DrpSupplierModel drpSupplierModel = new DrpSupplierModel();
//                     drpSupplierModel.setSupplierId(e.getWinSupplierId());
//                     drpSupplierModel.setSupplierName(e.getWinSupplierName());
//                     nearestSupplierList.add(drpSupplierModel);
//                  });
//               }
//
//               d.setNearestSupplierList(nearestSupplierList);
//               Long var10001 = d.getMaterialId();
//               DrpLastOrderGoodsVO drpLastOrderGoodsVO = (DrpLastOrderGoodsVO)orderGoodsVOMap.get("" + var10001 + "-" + d.getUnitId());
//               d.setLastOrderGoods(drpLastOrderGoodsVO);
//            });
//         }
//      }
//
//      return drpMaterialSupplierList;
//   }
//
//   public void bidMaterialSupplier(DrpBidMaterialSupplierDTO content) {
//      if (CollUtil.isNotEmpty(content.getMaterialIdList())) {
//         content.getMaterialIdList().forEach((materialId) -> {
//            content.setMaterialId(materialId);
//            this.packageData(content);
//         });
//      }
//
//      if (CollUtil.isNotEmpty(content.getCategoryIdList())) {
//         content.getCategoryIdList().forEach((categoryId) -> {
//            content.setCategoryId(categoryId);
//            this.packageData(content);
//         });
//      } else {
//         this.packageData(content);
//      }
//
//   }
//
//   private void packageData(DrpBidMaterialSupplierDTO content) {
//      DrpMenuMaterialSupplier drpMenuMaterialSupplier = (DrpMenuMaterialSupplier)this.drpMenuMaterialSupplierMapper.selectOne(((LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpMenuMaterialSupplier.class).eq(DrpMenuMaterialSupplier::getCanteenId, content.getCanteenId())).eq(DrpMenuMaterialSupplier::getDelFlag, DelFlagEnum.DEL_FALSE.key())).eq(ObjectUtil.isNotNull(content.getMaterialId()), DrpMenuMaterialSupplier::getMaterialId, content.getMaterialId())).eq(ObjectUtil.isNotNull(content.getCategoryId()), DrpMenuMaterialSupplier::getCategoryId, content.getCategoryId()));
//      if (ObjectUtil.isEmpty(drpMenuMaterialSupplier)) {
//         drpMenuMaterialSupplier = new DrpMenuMaterialSupplier();
//         drpMenuMaterialSupplier.setId(Id.next());
//         drpMenuMaterialSupplier.setSupplierId(content.getSupplierId());
//         drpMenuMaterialSupplier.setCanteenId(content.getCanteenId());
//         drpMenuMaterialSupplier.setMaterialId(content.getMaterialId());
//         drpMenuMaterialSupplier.setCategoryId(content.getCategoryId());
//         drpMenuMaterialSupplier.setDelFlag(DelFlagEnum.DEL_FALSE.key());
//         drpMenuMaterialSupplier.setAlternativeSupplier(content.getAlternativeSupplier());
//         drpMenuMaterialSupplier.setIfSupply(content.getIfSupply());
//         this.drpMenuMaterialSupplierMapper.insert(drpMenuMaterialSupplier);
//      } else {
//         drpMenuMaterialSupplier.setSupplierId(content.getSupplierId());
//         drpMenuMaterialSupplier.setMaterialId(content.getMaterialId());
//         drpMenuMaterialSupplier.setCanteenId(content.getCanteenId());
//         drpMenuMaterialSupplier.setCategoryId(content.getCategoryId());
//         drpMenuMaterialSupplier.setDelFlag(DelFlagEnum.DEL_FALSE.key());
//         drpMenuMaterialSupplier.setAlternativeSupplier(content.getAlternativeSupplier());
//         drpMenuMaterialSupplier.setIfSupply(content.getIfSupply());
//         this.drpMenuMaterialSupplierMapper.updateById(drpMenuMaterialSupplier);
//      }
//
//   }
//
//   public List<DrpMaterialSupplierVO> getMaterialSupplierByMaterialId(List<Long> materialIdList) {
//      return this.drpMenuMaterialSupplierMapper.getMaterialSupplierByMaterialId(materialIdList);
//   }
//
//   public List<DrpSupplierVO> listSupplierNew(DrpSupplierQueryDTO content) {
//      PageMethod.startPage(content.getPageNum(), content.getPageSize());
//      return ((DrpSupplierMapper)this.baseMapper).listSupplierNew(content, DrpSupplierStatusEnum.NORMAL.key(), DelFlagEnum.DEL_FALSE.key());
//   }
}
