package com.brilliance.isc.common.bop.cfa.cfabop.register.impl;

import com.brilliance.mda.runtime.mda.util.MdaUtils;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.bo.model.Cfabop;
import com.brilliance.isc.bo.model.CfaeadBizInfo;
import com.brilliance.isc.common.bop.cfa.cfabop.register.CfabopRegister;
import com.brilliance.isc.common.component.PtsptaToolComponent;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.brilliance.isc.vo.finance.DfdBizInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("dfd.cfabopRegister")
public class DfdCfabopRegisterImpl implements CfabopRegister {

    @Autowired
    private PtsptaToolComponent ptsptaToolComponent;

    @Override
    public void registerCfabopBizInfo(Cfabop cfabop, String cfatyp) {
        if(MdaUtils.isEmpty(cfatyp)){
            cspsLogger.warn("报送类型为空，组数结束!");
            return;
        }

        DfdBizInfoVo dfdbiz = (DfdBizInfoVo) cfabop.getRec();

        //依据报送类型 进行报送要素提取
        switch (cfatyp)
        {
            case "EAD":
                CfaeadBizInfo cfaeadBizInfo = cfabop.getCfaead().getCfaeadBizInfo();
                cfaeadBizInfo.setDfdownref(dfdbiz.getOwnref());
                cfaeadBizInfo.setMatdat(dfdbiz.getMatdat());
                cfaeadBizInfo.setStttendat(dfdbiz.getStttendat());
                cfaeadBizInfo.setActrat(dfdbiz.getActrat());
                cfaeadBizInfo.setFlttyp(dfdbiz.getFlttyp());
                cfaeadBizInfo.setBankcn(dfdbiz.getBankcn());
                cfaeadBizInfo.setRescur(dfdbiz.getRescur());
                cfaeadBizInfo.setResamt(dfdbiz.getResamt());
                cfaeadBizInfo.setOldmatdat(dfdbiz.getOldMatDat());
                cfaeadBizInfo.setOldctrat(dfdbiz.getOldactrat());
                Cbb maxcbb = (Cbb)cfabop.getCbsMap().get("MAX");
                if(!MdaUtils.isEmpty(maxcbb)){
                    cfaeadBizInfo.setMaxcur(maxcbb.getCur());
                    cfaeadBizInfo.setMaxamt(maxcbb.getAmt());
                }

                cfaeadBizInfo.setDff(ptsptaToolComponent.getPtsFromListByRol(cfabop.getPtsList(), "DFF"));

                break;
            default:
                break;
        }
    }
}
