package com.jwipc.order.convert;

import com.jwipc.order.dto.ShortagePlanReleaseDTO;
import com.jwipc.order.dto.ShortagePlanReplyDTO;
import com.jwipc.order.dto.UpdateShortagePlanSapDTO;
import com.jwipc.order.entity.ShortageData;
import com.jwipc.order.model.po.ShortagePlanReplyPO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;

import java.util.List;


@Mapper(componentModel = "spring")
public interface ShortageDataConvert {
    List<ShortageData> dtos2entities(List<ShortagePlanReleaseDTO> list);

    List<ShortagePlanReplyDTO> pos2Dtos(List<ShortagePlanReplyPO> replyPOS);

    List<ShortageData> dtos2entities1(List<ShortagePlanReplyDTO> list);

    
    @Mappings({
            @Mapping(source = "mainMaterialReplyDate", target = "EINDT",dateFormat="yyyyMMdd"),
            @Mapping(source = "mainMaterialReplyQuantity", target = "MENGE"),
            @Mapping(source = "supplierCode", target = "LIFNR"),
            @Mapping(source = "remark", target = "ZTEXT"),
            @Mapping(source = "mainMaterialReply", target = "ZBZ2"),
            @Mapping(source = "substituteMaterial1ReplyQuantity", target = "MNG_01"),
            @Mapping(source = "substituteMaterial1DeliveryDate", target = "PO_01", dateFormat="yyyyMMdd"),
            @Mapping(source = "substituteMaterial2ReplyQuantity", target = "MNG_02"),
            @Mapping(source = "substituteMaterial2DeliveryDate", target = "PO_02", dateFormat="yyyyMMdd"),
            @Mapping(source = "substituteMaterial3ReplyQuantity", target = "MNG_03"),
            @Mapping(source = "substituteMaterial3DeliveryDate", target = "PO_03", dateFormat="yyyyMMdd"),
            @Mapping(source = "successorMaterialReplyQuantity", target = "Z_HJHF"),
            @Mapping(source = "successorMaterialDeliveryDateReply", target = "Z_JJQ", dateFormat="yyyyMMdd")
    })
    UpdateShortagePlanSapDTO.ITData.Item fillItem(@MappingTarget UpdateShortagePlanSapDTO.ITData.Item item, ShortageData shortageDatum);
}
