package com.zzsmart.qomo.kn.cost.manage.vo;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class ZcorcProduct {
    private static final Logger logger = LoggerFactory.getLogger(ZcorcProduct.class);

    public String matnr;//物料号
    //public String aufnr;//工单号 实际成本才有
    public String posid;//wbs号
    public String werks;//工厂  实际成本才有
    //public String layer;//layer 实际成本才有
    public String version;//标准成本版本号 标准版本才有
    public double batch=1;//批量，用于计算标准成本

    public ZcorcProduct(String _ma,String _posid,String _we,String _layer,String _version){
        matnr=_ma;
        //aufnr=_an;
        posid=_posid;
        werks=_we;
        //layer=_layer;
        version=_version;
    }

    //public StageAccumulatedCost stageAccumulatedCost;//标准物料成本
    //public Map<String,StageAccumulatedCostWithBom> mapBom=new HashMap<>();
    //public Map<BomMaintenanceDetail,StageAccumulatedCost> mapBom=new HashMap<>();
    //public List<BomMaintenanceDetail> bomMaintenanceDetailList=new ArrayList<>();
    //public MaterialTree materialTree=new MaterialTree();//物料树
    public List<MaterialDiff> materialDiffs=new ArrayList<>();

    public List<ZcorcAufnr> nodeAufnrs=new ArrayList<>();//实际工单

    public double getPrice(){
        double rkst001=0;
        double rpmsmng=0;
        for (ZcorcAufnr zcorcAufnr:nodeAufnrs){
            rkst001+=zcorcAufnr.hiveSapZcorc.rkst001;
            rpmsmng+=zcorcAufnr.hiveSapZcorc.rpsmng;
        }
        if(rpmsmng>0) {
            return rkst001 / rpmsmng;
        }else{
            return 0;
        }
    }

    public double getKst005(){
        double rkst001=0;
        double rpmsmng=0;
        for (ZcorcAufnr zcorcAufnr:nodeAufnrs){
            rkst001+=zcorcAufnr.hiveSapZcorc.kst005*zcorcAufnr.hiveSapZcorc.rpsmng;
            rpmsmng+=zcorcAufnr.hiveSapZcorc.rpsmng;
        }
        if(rpmsmng>0) {
            return rkst001 / rpmsmng;
        }else{
            return 0;
        }
    }

    public double getKst003(){
        double rkst001=0;
        double rpmsmng=0;
        for (ZcorcAufnr zcorcAufnr:nodeAufnrs){
            rkst001+=zcorcAufnr.hiveSapZcorc.kst003*zcorcAufnr.hiveSapZcorc.rpsmng;
            rpmsmng+=zcorcAufnr.hiveSapZcorc.rpsmng;
        }
        if(rpmsmng>0) {
            return rkst001 / rpmsmng;
        }else{
            return 0;
        }
    }

    public double getRpsmng(){
        double rpmsmng=0;
        for (ZcorcAufnr zcorcAufnr:nodeAufnrs){
            rpmsmng+=zcorcAufnr.hiveSapZcorc.rpsmng;
        }
        return rpmsmng;
    }
}
