package com.brilliance.isc.common.trndoc.vo;

import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.bo.Spt;
import com.brilliance.isc.common.api.trndoc.vo.TrndocRequest;
import com.brilliance.isc.common.setfeg.vo.SetfegVo;
import com.brilliance.isc.common.setfog.vo.SetfogVo;
import com.brilliance.isc.common.setglg.vo.SetglgVo;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.BizAmdInfoVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;

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

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;

@Data
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class TrndocVo extends AbstractCommonVo {

    private BizInfoVo rec;
    private BizAmdInfoVo amdRec;
    private List<PtsptaVo> ptsptas;
    private List<DoceotVo> doceot;
    private Map<String, Cbb> cbsMap;
    /**
     * 结算分录信息
     */
    private SetglgVo setglg;
    /**
     * 我行收费信息
     */
    private SetfegVo setfeg;
    /**
     * 国外收费信息
     */
    private SetfogVo setfog;
    //SYSMOD.SPT
    private Spt spt;
    //Stream holding parameters for settlement 这里可能是输出给SetmodVo
    private IStream parstm = new StreamImpl();
    //holds old content of PDXFIXSTM
    private IStream oldpdxfixstm = new StreamImpl();
    //holds content of PDXFIXSTM
    private IStream pdxfixstm = new StreamImpl();
    //List of primary document names + implementation
    private IStream docnamstm = new StreamImpl();
    //Own Rid
    private String ownrid = NULLSTR;
    //Original Medium
    private String doccuroricortyp = NULLSTR;
    private String tag39ctxt = NULLSTR;
    private List<Map<String, String>> shwinc;
    private List<Map<String, String>> shwout;
    private  String tag77atxt = NULLSTR;

    private  String tag79txt = NULLSTR;
    private  String tag77jtxt = NULLSTR;
    //国内证通知书
    private  String advdoc = NULLSTR;
    //国内证落款
    private  String advnam = NULLSTR;
    //收支申报品种
    private  String boptyp = NULLSTR;

    public TrndocVo(TrndocRequest trndocRequest) {
        this.rec = trndocRequest.getRec();
        this.amdRec = trndocRequest.getAmdRec();
        this.ptsptas = trndocRequest.getPtsList();
        this.doceot = trndocRequest.getDoceot();
        this.cbsMap = trndocRequest.getCbsMap();
        this.setglg = trndocRequest.getSetglg();
        this.boptyp = trndocRequest.getBoptyp();
        this.setfeg = trndocRequest.getSetfeg();
        this.setfog = trndocRequest.getSetfog();
    }

    @Override
    public void reset() {
        if (rec == null) {
            rec = new BizInfoVo();
        }
        if (ptsptas == null) {
            ptsptas = new ArrayList<>();
        }
        ptsptas.forEach(ptsptaVo -> ptsptaVo.reset());
        if (doceot == null) {
            doceot = new ArrayList<>();
        }
        doceot.forEach(doceotVo -> doceotVo.reset());
        if (spt == null) {
            spt = new Spt();
        }
        if (parstm == null) {
            parstm = new StreamImpl();
        }
        if (oldpdxfixstm == null) {
            oldpdxfixstm = new StreamImpl();
        }
        if (pdxfixstm == null) {
            pdxfixstm = new StreamImpl();
        }
        if (amdRec == null) {
            amdRec = new BizAmdInfoVo();
        }
        amdRec.reset();
        if (setglg == null) {
            setglg = new SetglgVo();
        }
        setglg.reset();
    }
}
