package com.jwipc.order.convert;

import com.jwipc.order.dto.CreateShortagePlanDTO;
import com.jwipc.order.entity.ShortageDetail;
import com.jwipc.order.entity.ShortageHana;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;


@Mapper(componentModel = "spring")
public interface CreateShortagePlanHanaConvert {
    @Mappings({
            @Mapping(target = "shortageVersion", source = "ZVer"),
            @Mapping(target = "demandDate" ,expression="java(itDatum.ZXqrq != null && !itDatum.ZXqrq.trim().isEmpty() ? java.time.LocalDate.parse( itDatum.ZXqrq, java.time.format.DateTimeFormatter.ofPattern( \"yyyyMMdd\" )) :null)"),
            @Mapping(target = "factoryCode", source = "WERKS"),
            @Mapping(target = "workOrderNumber", source = "AUFNR"),
            @Mapping(target = "productCode", source = "MATNR"),
            @Mapping(target = "productLongName", source = "ZTDLINE"),
            @Mapping(target = "materialCode", source = "ZMATNR"),
            @Mapping(target = "materialLongName", source = "ZTDLINE2"),
            @Mapping(target = "materialGroup", source = "MATKL"),
            @Mapping(target = "demandQuantity", source = "BDMNG"),
            @Mapping(target = "materialGroupName", source = "WGBEZ"),
            @Mapping(target = "purchaseGroup", source = "EKGRP"),
            @Mapping(target = "currentQuantity", source = "ZKc"),
            @Mapping(target = "undeliveredPurchaseQuantity", source = "ZCgwjsl"),
            @Mapping(target = "shortageQuantity", source = "ZQlsl"),
            @Mapping(target = "purchaseRequestQuantity", source = "ZQgsl"),
            @Mapping(target = "qualityInspection", source = "ZZjkc"),
            @Mapping(target = "frozenInventory", source = "ZDjkc"),
            @Mapping(target = "checkFrozenInventory", source = "ZIQCBLOCK"),
            @Mapping(target = "defectiveWarehouseQuantity", source = "ZBlpkc"),
            @Mapping(target = "totalShortageQuantity", source = "ZHjqlsl"),
            @Mapping(target = "successorMaterial", source = "NFMAT"),
            @Mapping(target = "successorMaterialUndeliveredQuantity", source = "ZHjwj"),
            @Mapping(target = "substituteMaterial1", source = "MAT01"),
            @Mapping(target = "substituteMaterial1Inventory", source = "MNG01"),
            @Mapping(target = "substituteMaterial2", source = "MAT02"),
            @Mapping(target = "substituteMaterial2Inventory", source = "MNG02"),
            @Mapping(target = "substituteMaterial3", source = "MAT03"),
            @Mapping(target = "substituteMaterial3Inventory", source = "MNG03"),
            @Mapping(target = "zyichng", source = "ZYICHANG"),
            @Mapping(target = "launchDate",expression="java(itDatum.ZSXRQ != null && !itDatum.ZSXRQ.trim().isEmpty() ? java.time.LocalDate.parse( itDatum.ZSXRQ, java.time.format.DateTimeFormatter.ofPattern( \"yyyyMMdd\" )) :null)")
    })
    ShortageDetail convert1(CreateShortagePlanDTO.ITData itDatum);

    CreateShortagePlanDTO.ITData entityToDtoList(ShortageHana shortageHana);
}
