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

//import com.zzsmart.costanalysis.pojo.StandardProductprocess;

import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardProductprocess;

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

public class ZcorcAufnrDiff {
    public int id;
    public String layer;
    //public double rpsmg;//工单产出量
    //public double ppsmng;//成品用量
    public double bomuse;//标准结构bom用量
    public double productuse;//实际结构用量
    public double totalproductuse;//总实际结构用量
    public double totalbomuse;//总标准用量
    public String costcentername="";
    public String processname="";
    public String costcenter="";
    public String budat="";
    public String aufnr="";
    public String wbs="";
    public String matnr="";
    public String materialname="";
    public String posid;
    //public String code;
    // public String reason;
    public String detail;
    public String laborcode;
    public String laborreason;
    public String productcode;
    public String productreason;
    //public double batch = 1;
    //public double rate=1;
    public String rueck="";
    public double totalcostlabor=0;
    public double totalcostproduct=0;
    public UnitCost unitCost = new UnitCost();//实际费率
    public UnitCost standardCost = new UnitCost();//标准费率
    public HiveSapAfru hiveSapAfru;//实际工序
    public AppSceneCostStandardProductprocess productProcessMaintenance;//标准工序
    //public HiveSapAfru hiveSapAfru;//实际工序
    //public ProductProcessMaintenance productProcessMaintenance;//标准工序
    public AufnrCalculate laborCalculate = new AufnrCalculate();//人工
    public AufnrCalculate zjCalculate = new AufnrCalculate();//折旧
    public AufnrCalculate rdCalculate = new AufnrCalculate();//燃动
    public AufnrCalculate flCalculate = new AufnrCalculate();//辅料
    public AufnrCalculate qtCalculate = new AufnrCalculate();//其他
    public int realchildcount=0;
    public int stdchildcount=0;
    public List<String> aufnrs=new ArrayList<>();

    public List<String> getAufnrs() {
        return aufnrs;
    }

    public void setAufnrs(List<String> aufnrs) {
        this.aufnrs = aufnrs;
    }

    public int getRealchildcount() {
        return realchildcount;
    }

    public void setRealchildcount(int realchildcount) {
        this.realchildcount = realchildcount;
    }

    public int getStdchildcount() {
        return stdchildcount;
    }

    public void setStdchildcount(int stdchildcount) {
        this.stdchildcount = stdchildcount;
    }
    //public List<AufnrDiff> realChilds=new ArrayList<>();//实际工序来源
    //public List<AufnrDiff> stdChilds=new ArrayList<>();//标准工序来源

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getLayer() {
        return layer;
    }

    public void setLayer(String layer) {
        this.layer = layer;
    }

    public double getBomuse() {
        return bomuse;
    }

    public void setBomuse(double bomuse) {
        this.bomuse = bomuse;
    }

    public double getProductuse() {
        return productuse;
    }

    public void setProductuse(double productuse) {
        this.productuse = productuse;
    }

    public String getCostcentername() {
        return costcentername;
    }

    public void setCostcentername(String costcentername) {
        this.costcentername = costcentername;
    }

    public String getProcessname() {
        return processname;
    }

    public void setProcessname(String processname) {
        this.processname = processname;
    }

    public String getCostcenter() {
        return costcenter;
    }

    public void setCostcenter(String costcenter) {
        this.costcenter = costcenter;
    }

    public String getBudat() {
        return budat;
    }

    public void setBudat(String budat) {
        this.budat = budat;
    }

    public String getAufnr() {
        return aufnr;
    }

    public void setAufnr(String aufnr) {
        this.aufnr = aufnr;
    }

    public String getWbs() {
        return wbs;
    }

    public void setWbs(String wbs) {
        this.wbs = wbs;
    }

    public String getMatnr() {
        return matnr;
    }

    public void setMatnr(String matnr) {
        this.matnr = matnr;
    }

    public String getMaterialname() {
        return materialname;
    }

    public void setMaterialname(String materialname) {
        this.materialname = materialname;
    }

    public String getPosid() {
        return posid;
    }

    public void setPosid(String posid) {
        this.posid = posid;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getLaborcode() {
        return laborcode;
    }

    public void setLaborcode(String laborcode) {
        this.laborcode = laborcode;
    }

    public String getLaborreason() {
        return laborreason;
    }

    public void setLaborreason(String laborreason) {
        this.laborreason = laborreason;
    }

    public String getProductcode() {
        return productcode;
    }

    public void setProductcode(String productcode) {
        this.productcode = productcode;
    }

    public String getProductreason() {
        return productreason;
    }

    public void setProductreason(String productreason) {
        this.productreason = productreason;
    }

    public String getRueck() {
        return rueck;
    }

    public void setRueck(String rueck) {
        this.rueck = rueck;
    }

    public double getTotalcostlabor() {
        return totalcostlabor;
    }

    public void setTotalcostlabor(double totalcostlabor) {
        this.totalcostlabor = totalcostlabor;
    }

    public double getTotalcostproduct() {
        return totalcostproduct;
    }

    public void setTotalcostproduct(double totalcostproduct) {
        this.totalcostproduct = totalcostproduct;
    }

    public UnitCost getUnitCost() {
        return unitCost;
    }

    public void setUnitCost(UnitCost unitCost) {
        this.unitCost = unitCost;
    }

    public UnitCost getStandardCost() {
        return standardCost;
    }

    public void setStandardCost(UnitCost standardCost) {
        this.standardCost = standardCost;
    }

    public HiveSapAfru getHiveSapAfru() {
        return hiveSapAfru;
    }

    public void setHiveSapAfru(HiveSapAfru hiveSapAfru) {
        this.hiveSapAfru = hiveSapAfru;
    }

    public AppSceneCostStandardProductprocess getProductProcessMaintenance() {
        return productProcessMaintenance;
    }

    public void setProductProcessMaintenance(AppSceneCostStandardProductprocess productProcessMaintenance) {
        this.productProcessMaintenance = productProcessMaintenance;
    }

    public AufnrCalculate getLaborCalculate() {
        return laborCalculate;
    }

    public void setLaborCalculate(AufnrCalculate laborCalculate) {
        this.laborCalculate = laborCalculate;
    }

    public AufnrCalculate getZjCalculate() {
        return zjCalculate;
    }

    public void setZjCalculate(AufnrCalculate zjCalculate) {
        this.zjCalculate = zjCalculate;
    }

    public AufnrCalculate getRdCalculate() {
        return rdCalculate;
    }

    public void setRdCalculate(AufnrCalculate rdCalculate) {
        this.rdCalculate = rdCalculate;
    }

    public AufnrCalculate getFlCalculate() {
        return flCalculate;
    }

    public void setFlCalculate(AufnrCalculate flCalculate) {
        this.flCalculate = flCalculate;
    }

    public AufnrCalculate getQtCalculate() {
        return qtCalculate;
    }

    public void setQtCalculate(AufnrCalculate qtCalculate) {
        this.qtCalculate = qtCalculate;
    }


    public double getTotalDiff(){
        return laborCalculate.totaldiff+zjCalculate.totaldiff+rdCalculate.totaldiff+flCalculate.totaldiff+qtCalculate.totaldiff;
    }

    public double getLaborDiff(){
        return laborCalculate.totaldiff;
    }

    public double getProductDiff(){
        return zjCalculate.totaldiff+rdCalculate.totaldiff+flCalculate.totaldiff+qtCalculate.totaldiff;
    }

    public double getProductPriceDiff(){
        return zjCalculate.pricediff+rdCalculate.pricediff+flCalculate.pricediff+qtCalculate.pricediff;
    }

    public double getProductRealUse(){
        return zjCalculate.realuse+rdCalculate.realuse+flCalculate.realuse+qtCalculate.realuse;
    }

    public double getProductStdUse(){
        return zjCalculate.standarduse+rdCalculate.standarduse+flCalculate.standarduse+qtCalculate.standarduse;
    }

    public double getProductNumDiff(){
        return zjCalculate.numdiff+rdCalculate.numdiff+flCalculate.numdiff+qtCalculate.numdiff;
    }

    public double getStdProductcost(){
        return zjCalculate.getTotalStdCost()+rdCalculate.getTotalStdCost()+flCalculate.getTotalStdCost()+qtCalculate.getTotalStdCost();
    }

    public void MergeStandard(AufnrDiff aufnrDiff,double realcount){
        productProcessMaintenance=aufnrDiff.productProcessMaintenance;
        laborCalculate.stdnum=aufnrDiff.laborCalculate.stdnum;
        zjCalculate.stdnum=aufnrDiff.zjCalculate.stdnum;
        rdCalculate.stdnum=aufnrDiff.rdCalculate.stdnum;
        flCalculate.stdnum=aufnrDiff.flCalculate.stdnum;
        qtCalculate.stdnum=aufnrDiff.qtCalculate.stdnum;
        //batch=aufnrDiff.batch;
        bomuse=aufnrDiff.bomuse*laborCalculate.aufnruse/realcount;
        standardCost=aufnrDiff.standardCost;
       // stdChilds=aufnrDiff.stdChilds;
        Cal();
    }

    public ZcorcAufnrDiff(AppSceneCostStandardProductprocess pPm, double use) {
        productProcessMaintenance=pPm;
        processname = pPm.getProcessName();
        costcenter = pPm.getCostCenterCode();
        matnr = pPm.getMainPartNumber();
        bomuse = use;
        //batch=_batch;
        laborCalculate.stdnum = productProcessMaintenance.getLaborHour().doubleValue() + productProcessMaintenance.getPrepareHour().doubleValue();
        zjCalculate.stdnum = productProcessMaintenance.getMachineHour().doubleValue();
        rdCalculate.stdnum = productProcessMaintenance.getBurningHour().doubleValue();
        flCalculate.stdnum = productProcessMaintenance.getAuxiliaryHour().doubleValue();
        qtCalculate.stdnum = productProcessMaintenance.getOtherHour().doubleValue();
        //if(hourRate!=null){
        standardCost.rgfv=pPm.getLaborHourRate().doubleValue();
        standardCost.sbfv=pPm.getEquipHourRate().doubleValue();
        standardCost.flfv=pPm.getAuxiliaryHourRate().doubleValue();
        standardCost.rdfv=pPm.getFuelHourRate().doubleValue();
        standardCost.qtfv=pPm.getOtherHourRate().doubleValue();
        //}
        Cal();
    }

    public ZcorcAufnrDiff(NodeMatnr nodeMatnr,double _bomuse){
        HiveSapZcorc hiveSapZcorc=nodeMatnr.hiveSapZcorc;
        //hiveSapAfruList.add(hsa);
        layer=hiveSapZcorc.layer;
        aufnr=hiveSapZcorc.aufnr;
        wbs=hiveSapZcorc.ps_psp_pnr;
        //rueck = hsa.rueck;
        //budat = hsa.budat;
        //processname = hsa.ltxa1;
        //costcenter = hsa.kostl;
        matnr = hiveSapZcorc.matnr;
        //rate=_rate;
        //ppsmng=_ppsmng;
        productuse=_bomuse;
        totalcostproduct=hiveSapZcorc.rkst0051*productuse/hiveSapZcorc.menge;
        totalcostlabor=hiveSapZcorc.rkstlabor*productuse/hiveSapZcorc.menge;

        //laborCalculate.aufnrnum = (hsa.ism03 + hsa.ism01);
        //zjCalculate.aufnrnum=hsa.ism02;
        //rdCalculate.aufnrnum=hsa.ism04;
        // flCalculate.aufnrnum=hsa.ism05;
        //qtCalculate.aufnrnum=hsa.ism06;
        //unitCost=hsa.unitCost;
        Cal();
    }

    public ZcorcAufnrDiff(ZcorcMatnr nodeMatnr,double _bomuse){
        HiveSapZcorc hiveSapZcorc=nodeMatnr.hiveSapZcorc;
        //hiveSapAfruList.add(hsa);
        layer=hiveSapZcorc.layer;
        aufnr=hiveSapZcorc.aufnr;
        wbs=hiveSapZcorc.ps_psp_pnr;
        //rueck = hsa.rueck;
        //budat = hsa.budat;
        //processname = hsa.ltxa1;
        //costcenter = hsa.kostl;
        matnr = hiveSapZcorc.matnr;
        //rate=_rate;
        //ppsmng=_ppsmng;
        productuse=_bomuse;
        totalcostproduct=hiveSapZcorc.rkst0051*productuse/hiveSapZcorc.menge;
        totalcostlabor=hiveSapZcorc.rkstlabor*productuse/hiveSapZcorc.menge;

        //laborCalculate.aufnrnum = (hsa.ism03 + hsa.ism01);
        //zjCalculate.aufnrnum=hsa.ism02;
        //rdCalculate.aufnrnum=hsa.ism04;
        // flCalculate.aufnrnum=hsa.ism05;
        //qtCalculate.aufnrnum=hsa.ism06;
        //unitCost=hsa.unitCost;
        Cal();
    }

    public ZcorcAufnrDiff(HiveSapAfru hsa, HiveSapZcorc hiveSapZcorc,double _bomuse) {
        hiveSapAfru=hsa;
        layer=hiveSapZcorc.layer;
        aufnr=hiveSapZcorc.aufnr;
        wbs=hiveSapZcorc.ps_psp_pnr;
        rueck = hsa.rueck;
        budat = hsa.budat;
        processname = hsa.ltxa1;
        costcenter = hsa.kostl;
        matnr = hiveSapZcorc.matnr;
        //rate=_rate;
        //ppsmng=_ppsmng;
        productuse=_bomuse;
        posid=hiveSapZcorc.posid;
        double lmnga = hiveSapAfru.lmnga;

        laborCalculate.aufnrnum = (hsa.ism03 + hsa.ism01)/lmnga;
        zjCalculate.aufnrnum=hsa.ism02/lmnga;
        rdCalculate.aufnrnum=hsa.ism04/lmnga;
        flCalculate.aufnrnum=hsa.ism05/lmnga;
        qtCalculate.aufnrnum=hsa.ism06/lmnga;
        unitCost=hsa.unitCost;
        realchildcount=1;
        Cal();
        //rpsmg=hiveSapZcorc.rpsmng;
    }

    public ZcorcAufnrDiff() {

    }

    public void Cal() {
        laborCalculate.bomuse = bomuse;
        laborCalculate.aufnruse = productuse;
        laborCalculate.standardcost = standardCost.rgfv;
        laborCalculate.realcost = unitCost.rgfv;
        laborCalculate.ReCal();

        zjCalculate.bomuse = bomuse;
        zjCalculate.aufnruse = productuse;
        zjCalculate.standardcost =  standardCost.sbfv;
        zjCalculate.realcost = unitCost.sbfv;
        zjCalculate.ReCal();

        rdCalculate.bomuse = bomuse;
        rdCalculate.aufnruse = productuse;
        rdCalculate.standardcost =  standardCost.rdfv;
        rdCalculate.realcost = unitCost.rdfv;
        rdCalculate.ReCal();

        flCalculate.bomuse = bomuse;
        flCalculate.aufnruse = productuse;
        flCalculate.standardcost =  standardCost.flfv;
        flCalculate.realcost = unitCost.flfv;
        flCalculate.ReCal();

        qtCalculate.bomuse = bomuse;
        qtCalculate.aufnruse = productuse;
        qtCalculate.standardcost =  standardCost.qtfv;
        qtCalculate.realcost = unitCost.qtfv;
        qtCalculate.ReCal();

        if(hiveSapAfru!=null){
            totalcostproduct=qtCalculate.getTotalRealCost()+flCalculate.getTotalRealCost()+rdCalculate.getTotalRealCost()+zjCalculate.getTotalRealCost();
            totalcostlabor=laborCalculate.getTotalRealCost();
        }
    }
}
