package com.hys.app.converter.erp;

import com.hys.app.framework.database.WebPage;
import com.hys.app.framework.util.DateUtil;
import com.hys.app.model.erp.dos.StockTransferDO;
import com.hys.app.model.erp.dos.StockTransferProductDO;
import com.hys.app.model.erp.dto.StockTransferDTO;
import com.hys.app.model.erp.dto.StockUpdateDTO;
import com.hys.app.model.erp.enums.NoBusinessTypeEnum;
import com.hys.app.model.erp.enums.StockOperateEnum;
import com.hys.app.model.erp.vo.StockTransferVO;
import com.hys.app.service.erp.NoGenerateManager;
import org.mapstruct.Mapper;
import org.mapstruct.MappingConstants;

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

/**
 * 库存调拨 Convert
 *
 * @author 张崧
 * @since 2023-12-12 11:59:06
 */
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface StockTransferConverter {

    StockTransferDO convert(StockTransferDTO stockTransferDTO);

    StockTransferVO convert(StockTransferDO stockTransferDO);

    List<StockTransferVO> convert(List<StockTransferDO> list);

    WebPage<StockTransferVO> convert(WebPage<StockTransferDO> webPage);

    default List<StockUpdateDTO> convertStockUpdateList(List<StockTransferProductDO> transferProductList) {
        return transferProductList.stream().map(transferProductDO -> {
            StockUpdateDTO stockUpdateDTO = new StockUpdateDTO();

            stockUpdateDTO.setBatchId(transferProductDO.getWarehouseEntryBatchId());
            stockUpdateDTO.setTip(transferProductDO.getProductName());
            stockUpdateDTO.setOperate(StockOperateEnum.Reduce);
            stockUpdateDTO.setChangeNum(transferProductDO.getNum());

            return stockUpdateDTO;
        }).collect(Collectors.toList());
    }



}

