package com.brilliance.isc.common.api.diary.vo;

import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.liaallg.vo.LiaallgVo;
import com.brilliance.isc.common.setfeg.vo.SetfegVo;
import com.brilliance.isc.common.trndia.vo.DiaVo;
import com.brilliance.isc.common.trndia.vo.TrndiaVo;
import com.brilliance.isc.common.trndoc.vo.DoceotVo;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

@Data
@ApiModel(value = "备忘录请求信息", description = "备忘录请求信息")
public class DiaryRequestVo<T1 extends BizInfoVo, T2 extends BizAmdInfoVo> extends AbstractCommonVo {

    @ApiModelProperty(value = "当前交易码", name = "transName", required = true)
    private String transName = NULLSTR;

    @ApiModelProperty(value = "当前经办人员ID", name = "userId", required = true)
    private String userId = NULLSTR;

    @ApiModelProperty(value = "业务摘要信息", name = "rec", required = true)
    private T1 rec;

    @ApiModelProperty(value = "业务摘要修改信息", name = "rec", required = true)
    private T2 amdRec;

    @ApiModelProperty(value = "CBB列表", name = "cbsMap", required = true)
    private Map<String, Cbb> cbsMap;

    @ApiModelProperty(value = "交易角色参与方列表", name = "ptsList", required = true)
    private List<PtsptaVo> ptsList;

    @ApiModelProperty(value = "表外条目", name = "liaallg", required = true)
    private List<LiaallgVo> liaallg;

    //是否读取过前手数据 X表示已经读取过
    @ApiModelProperty(value = "是否读取过前手数据", name = "oldredflg", required = true)
    private String oldredflg;

    //结算金额 来源setmod.setamt
    @ApiModelProperty(value = "结算金额", name = "setamt", required = true)
    private BigDecimal setamt = BigDecimal.ZERO;

    //结算币种
    @ApiModelProperty(value = "结算币种", name = "setcur", required = true)
    private String setcur = "";

    @ApiModelProperty(value = "备忘录列表", name = "dias", required = true)
    private List<DiaVo> dias;

    private SetfegVo setfeg;

    //报文面函条目
    private List<DoceotVo> doceot;

    //备忘录计算模型
    @ApiModelProperty(hidden = true)
    private TrndiaVo trndiaVo;

    @Override
    public void reset() {
        if (rec == null) {
            rec = (T1) new BizInfoVo();
        }
        if (amdRec == null) {
            amdRec = (T2)new BizAmdInfoVo();
        }
        amdRec.reset();
        if (cbsMap == null) {
            cbsMap = new HashMap<>();
        }
        if (ptsList == null) {
            ptsList = new ArrayList<>();
        }
        ptsList.forEach(p -> p.reset());
        if (setfeg == null) {
            setfeg = new SetfegVo();
        }
        setfeg.reset();
        if (trndiaVo == null) {
            trndiaVo = new TrndiaVo(this);
        }
        trndiaVo.reset();
    }
}
