package com.fjhx.params.v3;

import com.fjhx.entity.v3.V3PlanStatistics;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;

public class PlanDataMap extends HashMap<String, V3PlanStatistics> {

    public V3PlanStatistics get(Long userId, String planMaterial, Date planTime, Date createTime) {
        String key = userId + planMaterial + planTime;

        V3PlanStatistics v3PlanStatistics = get(key);
        if (v3PlanStatistics == null) {
            v3PlanStatistics = createV3PlanStatistics(userId, planMaterial, planTime, createTime);
            put(key, v3PlanStatistics);
        }

        return v3PlanStatistics;
    }

    private V3PlanStatistics createV3PlanStatistics(Long userId, String planMaterial, Date planDate, Date createTime) {
        V3PlanStatistics stockBackPlanDetails = new V3PlanStatistics();
        stockBackPlanDetails.setPlanMaterial(planMaterial);
        stockBackPlanDetails.setPlanDate(planDate);
        stockBackPlanDetails.setUserId(userId);
        stockBackPlanDetails.setPlanArea(BigDecimal.ZERO);

        stockBackPlanDetails.setPickingMoney(BigDecimal.ZERO);
        stockBackPlanDetails.setPickingNum(0);
        stockBackPlanDetails.setPickingMeters(BigDecimal.ZERO);
        stockBackPlanDetails.setPickingArea(BigDecimal.ZERO);

        stockBackPlanDetails.setBackMoney(BigDecimal.ZERO);
        stockBackPlanDetails.setBackNum(0);
        stockBackPlanDetails.setBackMeters(BigDecimal.ZERO);
        stockBackPlanDetails.setBackArea(BigDecimal.ZERO);

        stockBackPlanDetails.setTransferOutMoney(BigDecimal.ZERO);
        stockBackPlanDetails.setTransferOutMeters(BigDecimal.ZERO);
        stockBackPlanDetails.setTransferOutArea(BigDecimal.ZERO);
        stockBackPlanDetails.setTransferOutNum(0);

        stockBackPlanDetails.setTransferInMoney(BigDecimal.ZERO);
        stockBackPlanDetails.setTransferInMeters(BigDecimal.ZERO);
        stockBackPlanDetails.setTransferInArea(BigDecimal.ZERO);
        stockBackPlanDetails.setTransferInNum(0);

        stockBackPlanDetails.setCreateTime(createTime);

        return stockBackPlanDetails;
    }

}
